def get_all_event_names(self):
     """
     Return all event names in current samples dir.
     """
     all_event_names = []
     for curr_fname in self.all_filenames:
         if curr_fname.endswith(".miso"):
             # It's a regular .miso plain text file
             event_name = \
               get_event_name(curr_fname,
                              use_compressed_map=self.compressed_ids_to_genes)
             # Record event name and its mapping to a .miso file
             all_event_names.append(event_name)
             self.event_names_to_fnames[event_name] = curr_fname
         elif miso_db.is_miso_db_fname(curr_fname):
             # It's a MISO database file, so load all the event
             # names in that file
             curr_db = \
               miso_db.MISODatabase(curr_fname,
                                    comp_to_uncomp=self.compressed_ids_to_genes)
             # Record event name and its mapping to the chromosome's
             # .miso_db file
             for curr_event_name in curr_db.get_all_event_names():
                 curr_event_name = str(curr_event_name)
                 event_name_to_use = curr_event_name
                 # If we're given a mapping of compressed IDs, use the
                 # mapping to get the uncompressed event name
                 if self.compressed_ids_to_genes is not None:
                     # The internal database representation of compressed
                     # index databases are compressed IDs, so if the
                     # ID is uncompressed it must be converted to a
                     # compressed one.
                     if not misc_utils.is_compressed_name(curr_event_name):
                         event_name_to_use = \
                           str(curr_db.uncomp_to_comp[curr_event_name])
                 all_event_names.append(event_name_to_use)
                 self.event_names_to_fnames[event_name_to_use] = curr_fname
     return all_event_names
Example #2
0
 def get_all_event_names(self):
     """
     Return all event names in current samples dir.
     """
     all_event_names = []
     for curr_fname in self.all_filenames:
         if curr_fname.endswith(".miso"):
             # It's a regular .miso plain text file
             event_name = \
               get_event_name(curr_fname,
                              use_compressed_map=self.compressed_ids_to_genes)
             # Record event name and its mapping to a .miso file
             all_event_names.append(event_name)
             self.event_names_to_fnames[event_name] = curr_fname
         elif miso_db.is_miso_db_fname(curr_fname):
             # It's a MISO database file, so load all the event
             # names in that file
             curr_db = \
               miso_db.MISODatabase(curr_fname,
                                    comp_to_uncomp=self.compressed_ids_to_genes)
             # Record event name and its mapping to the chromosome's
             # .miso_db file
             for curr_event_name in curr_db.get_all_event_names():
                 curr_event_name = str(curr_event_name)
                 event_name_to_use = curr_event_name
                 # If we're given a mapping of compressed IDs, use the
                 # mapping to get the uncompressed event name
                 if self.compressed_ids_to_genes is not None:
                     # The internal database representation of compressed
                     # index databases are compressed IDs, so if the
                     # ID is uncompressed it must be converted to a
                     # compressed one.
                     if not misc_utils.is_compressed_name(curr_event_name):
                         event_name_to_use = \
                           str(curr_db.uncomp_to_comp[curr_event_name])
                 all_event_names.append(event_name_to_use)
                 self.event_names_to_fnames[event_name_to_use] = curr_fname
     return all_event_names
 def get_event_samples(self, event_name):
     """
     Get the samples information for the given event by name.
     """
     samples = None
     if event_name not in self.event_names_to_fnames:
         return None
     event_fname = self.event_names_to_fnames[event_name]
     if event_fname.endswith(".miso"):
         # Get event from plain text .miso file
         f = open(event_fname, "r")
         samples = load_samples(f)
         f.close()
     elif miso_db.is_miso_db_fname(event_fname):
         # Get event from miso_db file
         curr_db = \
           miso_db.MISODatabase(event_fname,
                                comp_to_uncomp=self.compressed_ids_to_genes)
         event_data = curr_db.get_event_data_as_stream(event_name)
         samples = load_samples(event_data)
     if samples is None:
         print "WARNING: Could not parse event %s samples" % (event_name)
     return samples
Example #4
0
 def get_event_samples(self, event_name):
     """
     Get the samples information for the given event by name.
     """
     samples = None
     if event_name not in self.event_names_to_fnames:
         return None
     event_fname = self.event_names_to_fnames[event_name]
     if event_fname.endswith(".miso"):
         # Get event from plain text .miso file
         f = open(event_fname, "r")
         samples = load_samples(f)
         f.close()
     elif miso_db.is_miso_db_fname(event_fname):
         # Get event from miso_db file
         curr_db = \
           miso_db.MISODatabase(event_fname,
                                comp_to_uncomp=self.compressed_ids_to_genes)
         event_data = curr_db.get_event_data_as_stream(event_name)
         samples = load_samples(event_data)
     if samples is None:
         print "WARNING: Could not parse event %s samples" %(event_name)
     return samples