Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
""" Manage storage of per-gene data. """
""" Per-batch meta-data. """
""" Create metadata for for some genes. """
#: The number of genes.
#: The organism these are genes of.
""" A collection of genes with some associated data.
This must be consistent between all profiles that are processed together. """
""" Initialize the genes. """ #: Convenient access to the number of genes.
#: The sorted upper-case names of genes in the set.
#: The full gene set this is derived from.
#: The unique identifier of this list of gene names.
""" Return a list of the available data. """
""" Whether there exists some per-gene data. """
""" Load a per-gene data array. """
""" Load a per-gene data array. """
""" Load genes from a directory. """ raise RuntimeError('The genes set metadata file: %s ' 'specifies the wrong organism: %s ' 'instead of the expected: %s' % (metadata.yaml_path, metadata.organism, organism))
""" Write the ``genes.yaml`` file after creating a genes directory.
At minimum, the directory should contain the gene names file. """ names_path = os.path.join(path, 'g.name.txt') names = np.ArrayStr.read(names_path[:-4]) with open(os.path.join(path, 'genes.yaml'), 'w') as file: file.write('uuid: %s\n' % file_uuid(names_path)) file.write('organism: %s\n' % organism) file.write('genes_count: %s\n' % len(names))
""" A set of genes with some associated data.
This must be consistent between all batches that are processed together. """
""" Open a genes set directory for access. """ #: The meta-data describing the genes.
'in line: %s ' 'of the genes set file: %s/genes.name.txt' % (name, index + 1, self.metadata.path)) % (self.metadata.path, index, index + 1))
'specifies a different UUID: %s ' 'than the md5sum: %s ' 'of the gene names file: %s/genes.name.txt' % (self.metadata.yaml_path, self.metadata.uuid, self.uuid, self.metadata.path))
'specifies a different genes count: %s ' 'than the number of genes: %s ' 'in the genes names file: %s/genes.name.txt' % (self.metadata.yaml_path, self.metadata.genes_count, len(self.names), self.metadata.path))
return sorted([data['name'] for data in glob_extract(optional(os.path.join(self.metadata.path, 'g.{*name}.{*type}')))])
""" Return the path of a data file in the genes directory. """ return os.path.join(self.metadata.path, path)
return Stat.exists(os.path.join(self.metadata.path, 'g.%s.txt' % name)) \ or Stat.exists(os.path.join(self.metadata.path, 'g.%s.npy' % name))
np.BaseArray.read_array(os.path.join(self.metadata.path, 'g.' + name)))
""" A subset of some genes. """
""" Create a subset of some genes. """
#: The genes this is a subset of.
#: The indices of the superset genes which are included in the subset.
return self.superset.available_data()
return self.superset.has_array(name)
|