Esempio n. 1
0
def load_metadata(filename):
    """Load cluster metadata from a CSV file.

    Return (field_name, dictionary).

    """
    return _read_tsv_simple(filename)
Esempio n. 2
0
def _load(path):
    path = str(path)
    if path.endswith('.npy'):
        return np.load(path)
    elif path.endswith(('.csv', '.tsv')):
        return _read_tsv_simple(path)[1]  # the function returns a tuple (field, data)
    elif path.endswith('.bin'):
        # TODO: configurable dtype
        return np.fromfile(path, np.int16)
Esempio n. 3
0
    def write_cluster_data(self):
        """We load all cluster metadata from TSV files, renumber the clusters,
        merge the dictionaries, and save in a new merged TSV file. """

        cluster_data = [
            'cluster_Amplitude.tsv', 'cluster_ContamPct.tsv',
            'cluster_KSLabel.tsv'
        ]

        for fn in cluster_data:
            metadata = {}
            for subdir, offset in zip(self.subdirs, self.cluster_offsets):
                try:
                    field_name, metadata_loc = _read_tsv_simple(subdir / fn)
                except ValueError:
                    # Skipping non-existing file.
                    continue
                for k, v in metadata_loc.items():
                    metadata[k + offset] = v
            if metadata:
                _write_tsv_simple(self.out_dir / fn, field_name, metadata)