Previous CloneSet | Next CloneSet | Back to Main Report |
Clone Mass | Clones in CloneSet | Parameter Count | Clone Similarity | Syntax Category [Sequence Length] |
---|---|---|---|---|
114 | 2 | 1 | 0.999 | file_input_element_list[3] |
Clone Abstraction | Parameter Bindings |
Clone Instance (Click to see clone) | Line Count | Source Line | Source File |
---|---|---|---|
1 | 114 | 13 | Bio/MEME/Parser.py |
2 | 114 | 103 | Bio/Motif/Parsers/MEME.py |
| ||||
class MEMERecord: """A class for holding the results of a MEME run. A MEMERecord is an object that holds the results from running MEME. It implements no methods of its own. """ def __init__ (self): "__init__ (self)" self.motifs = [ ] self.version = "" self.datafile = "" self.command = "" self.alphabet = None self.sequence_names = [ ] def get_motif_by_name (self,name): for m in self.motifs: if m.name==name: return m class MEMEParser(AbstractParser): '''A parser for the text output of the MEME program. Parses the output into an object of the MEMERecord class. Methods: parse (handle): parses the contents of the file handle passed to it. Example: f = open("meme.output.txt") parser = MEMEParser() meme_record = parser.parse(f) for motif in meme_record.motifs: for instance in motif.instances: print instance.motif_name, instance.sequence_name, instance.strand, instance.pvalue ''' def __init__ (self): "__init__ (self)" self._scanner = _MEMEScanner( ) self._consumer = _MEMEConsumer( ) def parse (self,handle): "parse (self, handle)" self._scanner.feed(handle,self._consumer) return self._consumer.data class _MEMEScanner: """Scanner for MEME output. Methods: feed """ def feed (self,handle,consumer): """ Feeds in MEME output for scanning. handle should implement the readline method. consumer is a Consumer object that can receive the salient events. """ if isinstance(handle,File.UndoHandle): uhandle = handle else: uhandle = File.UndoHandle(handle) self._scan_header(uhandle,consumer) self._scan_motifs (uhandle,consumer) def _scan_header(self,uhandle,consumer): try : read_and_call_until(uhandle,consumer.noevent,contains = "MEME version") except ValueError: raise ValueError("Improper input file. File should contain a line starting MEME version.") read_and_call(uhandle,consumer._version,start = "MEME version") read_and_call_until(uhandle,consumer.noevent,start = "TRAINING SET") read_and_call(uhandle,consumer.noevent,start = "TRAINING SET") read_and_call(uhandle,consumer.noevent,start = "****") read_and_call(uhandle,consumer._datafile,start = "DATAFILE") read_and_call(uhandle,consumer._alphabet,start = "ALPHABET") read_and_call(uhandle,consumer.noevent,start = "Sequence name") read_and_call(uhandle,consumer.noevent,start = "----") read_and_call_until(uhandle,consumer._sequence_name,start = "***") read_and_call_until(uhandle,consumer.noevent,start = "command:") read_and_call(uhandle,consumer._commandline,start = "command:") read_and_call_until(uhandle,consumer.noevent,start = "MOTIF 1") def _scan_motifs(self,uhandle,consumer): while 1: read_and_call(uhandle,consumer._add_motif_with_info,start = "MOTIF") read_and_call_until(uhandle,consumer.noevent,contains = "sorted by position p-value") read_and_call(uhandle,consumer.motif_name,contains = "sorted by position p-value") read_and_call(uhandle,consumer.noevent,start = "---") read_and_call(uhandle,consumer.noevent,start = "Sequence name") read_and_call(uhandle,consumer.noevent,start = "---") read_and_call_until(uhandle,consumer.add_instance,start = "---") read_and_call_until(uhandle,consumer.noevent,start = "log-odds matrix") read_and_call(uhandle,consumer.noevent) read_and_call_until(uhandle,consumer.add_to_logodds,start = "---") read_and_call_until(uhandle,consumer.noevent,start = "letter-probability matrix") read_and_call(uhandle,consumer.noevent,start = "letter-probability matrix") read_and_call_until(uhandle,consumer.add_to_pssm,start = "---") read_and_call_until(uhandle,consumer.noevent,start = "Time") read_and_call(uhandle,consumer.noevent,start = "Time") read_and_call(uhandle,consumer.noevent,blank = 1) read_and_call(uhandle,consumer.noevent,start = "***") read_and_call_while(uhandle,consumer.noevent,blank = 1) read_and_call(uhandle,consumer.noevent,start = "***") line = safe_peekline(uhandle) if line.startswith("SUMMARY OF MOTIFS"): break |
| ||||
class MEMERecord: """A class for holding the results of a MEME run. A MEMERecord is an object that holds the results from running MEME. It implements no methods of its own. """ def __init__ (self): "__init__ (self)" self.motifs = [ ] self.version = "" self.datafile = "" self.command = "" self.alphabet = None self.sequence_names = [ ] def get_motif_by_name (self,name): for m in self.motifs: if m.name==name: return m class MEMEParser(AbstractParser): '''A parser for the text output of the MEME program. Parses the output into an object of the MEMERecord class. Methods: parse (handle): parses the contents of the file handle passed to it. Example: >>>f = open("meme.output.txt") >>>parser = MEMEParser() >>>meme_record = parser.parse(f) >>>for motif in meme_record.motifs: ... for instance in motif.instances: ... print instance.motif_name, instance.sequence_name, instance.strand, instance.pvalue ''' def __init__ (self): "__init__ (self)" self._scanner = _MEMEScanner( ) self._consumer = _MEMEConsumer( ) def parse (self,handle): "parse (self, handle)" self._scanner.feed(handle,self._consumer) return self._consumer.data class _MEMEScanner: """Scanner for MEME output. Methods: feed """ def feed (self,handle,consumer): """ Feeds in MEME output for scanning. handle should implement the readline method. consumer is a Consumer object that can receive the salient events. """ if isinstance(handle,File.UndoHandle): uhandle = handle else: uhandle = File.UndoHandle(handle) self._scan_header(uhandle,consumer) self._scan_motifs (uhandle,consumer) def _scan_header(self,uhandle,consumer): try : read_and_call_until(uhandle,consumer.noevent,contains = "MEME version") except ValueError: raise ValueError("Improper input file. File should contain a line starting MEME version.") read_and_call(uhandle,consumer._version,start = "MEME version") read_and_call_until(uhandle,consumer.noevent,start = "TRAINING SET") read_and_call(uhandle,consumer.noevent,start = "TRAINING SET") read_and_call(uhandle,consumer.noevent,start = "****") read_and_call(uhandle,consumer._datafile,start = "DATAFILE") read_and_call(uhandle,consumer._alphabet,start = "ALPHABET") read_and_call(uhandle,consumer.noevent,start = "Sequence name") read_and_call(uhandle,consumer.noevent,start = "----") read_and_call_until(uhandle,consumer._sequence_name,start = "***") read_and_call_until(uhandle,consumer.noevent,start = "command:") read_and_call(uhandle,consumer._commandline,start = "command:") read_and_call_until(uhandle,consumer.noevent,start = "MOTIF 1") def _scan_motifs(self,uhandle,consumer): while 1: read_and_call(uhandle,consumer._add_motif_with_info,start = "MOTIF") read_and_call_until(uhandle,consumer.noevent,contains = "sorted by position p-value") read_and_call(uhandle,consumer.motif_name,contains = "sorted by position p-value") read_and_call(uhandle,consumer.noevent,start = "---") read_and_call(uhandle,consumer.noevent,start = "Sequence name") read_and_call(uhandle,consumer.noevent,start = "---") read_and_call_until(uhandle,consumer.add_instance,start = "---") read_and_call_until(uhandle,consumer.noevent,start = "log-odds matrix") read_and_call(uhandle,consumer.noevent) read_and_call_until(uhandle,consumer.add_to_logodds,start = "---") read_and_call_until(uhandle,consumer.noevent,start = "letter-probability matrix") read_and_call(uhandle,consumer.noevent,start = "letter-probability matrix") read_and_call_until(uhandle,consumer.add_to_pssm,start = "---") read_and_call_until(uhandle,consumer.noevent,start = "Time") read_and_call(uhandle,consumer.noevent,start = "Time") read_and_call(uhandle,consumer.noevent,blank = 1) read_and_call(uhandle,consumer.noevent,start = "***") read_and_call_while(uhandle,consumer.noevent,blank = 1) read_and_call(uhandle,consumer.noevent,start = "***") line = safe_peekline(uhandle) if line.startswith("SUMMARY OF MOTIFS"): break |
| |||
class MEMERecord: """A class for holding the results of a MEME run. A MEMERecord is an object that holds the results from running MEME. It implements no methods of its own. """ def __init__(self): "__init__ (self)" self.motifs = [ ] self.version = "" self.datafile = "" self.command = "" self.alphabet = None self.sequence_names = [ ] def get_motif_by_name(self,name): for m in self.motifs: if m.name==name: return m class MEMEParser(AbstractParser): [[#variable6afd02e0]] def __init__(self): "__init__ (self)" self._scanner = _MEMEScanner( ) self._consumer = _MEMEConsumer( ) def parse(self,handle): "parse (self, handle)" self._scanner.feed(handle,self._consumer) return self._consumer.data class _MEMEScanner: """Scanner for MEME output. Methods: feed """ def feed(self,handle,consumer): """ Feeds in MEME output for scanning. handle should implement the readline method. consumer is a Consumer object that can receive the salient events. """ if isinstance(handle,File.UndoHandle): uhandle = handle else: uhandle = File.UndoHandle(handle) self._scan_header(uhandle,consumer) self._scan_motifs(uhandle,consumer) def _scan_header(self,uhandle,consumer): try : read_and_call_until(uhandle,consumer.noevent,contains = "MEME version") except ValueError: raise ValueError("Improper input file. File should contain a line starting MEME version.") read_and_call(uhandle,consumer._version,start = "MEME version") read_and_call_until(uhandle,consumer.noevent,start = "TRAINING SET") read_and_call(uhandle,consumer.noevent,start = "TRAINING SET") read_and_call(uhandle,consumer.noevent,start = "****") read_and_call(uhandle,consumer._datafile,start = "DATAFILE") read_and_call(uhandle,consumer._alphabet,start = "ALPHABET") read_and_call(uhandle,consumer.noevent,start = "Sequence name") read_and_call(uhandle,consumer.noevent,start = "----") read_and_call_until(uhandle,consumer._sequence_name,start = "***") read_and_call_until(uhandle,consumer.noevent,start = "command:") read_and_call(uhandle,consumer._commandline,start = "command:") read_and_call_until(uhandle,consumer.noevent,start = "MOTIF 1") def _scan_motifs(self,uhandle,consumer): while 1: read_and_call(uhandle,consumer._add_motif_with_info,start = "MOTIF") read_and_call_until(uhandle,consumer.noevent,contains = "sorted by position p-value") read_and_call(uhandle,consumer.motif_name,contains = "sorted by position p-value") read_and_call(uhandle,consumer.noevent,start = "---") read_and_call(uhandle,consumer.noevent,start = "Sequence name") read_and_call(uhandle,consumer.noevent,start = "---") read_and_call_until(uhandle,consumer.add_instance,start = "---") read_and_call_until(uhandle,consumer.noevent,start = "log-odds matrix") read_and_call(uhandle,consumer.noevent) read_and_call_until(uhandle,consumer.add_to_logodds,start = "---") read_and_call_until(uhandle,consumer.noevent,start = "letter-probability matrix") read_and_call(uhandle,consumer.noevent,start = "letter-probability matrix") read_and_call_until(uhandle,consumer.add_to_pssm,start = "---") read_and_call_until(uhandle,consumer.noevent,start = "Time") read_and_call(uhandle,consumer.noevent,start = "Time") read_and_call(uhandle,consumer.noevent,blank = 1) read_and_call(uhandle,consumer.noevent,start = "***") read_and_call_while(uhandle,consumer.noevent,blank = 1) read_and_call(uhandle,consumer.noevent,start = "***") line = safe_peekline(uhandle) if line.startswith("SUMMARY OF MOTIFS"): break |
CloneAbstraction |
Parameter Index | Clone Instance | Parameter Name | Value |
---|---|---|---|
1 | 1 | [[#6afd02e0]] | '''A parser for the text output of the MEME program. Parses the output into an object of the MEMERecord class. Methods: parse (handle): parses the contents of the file handle passed to it. Example: >>>f = open("meme.output.txt") >>>parser = MEMEParser() >>>meme_record = parser.parse(f) >>>for motif in meme_record.motifs: ... for instance in motif.instances: ... print instance.motif_name, instance.sequence_name, instance.strand, instance.pvalue ''' |
1 | 2 | [[#6afd02e0]] | '''A parser for the text output of the MEME program. Parses the output into an object of the MEMERecord class. Methods: parse (handle): parses the contents of the file handle passed to it. Example: f = open("meme.output.txt") parser = MEMEParser() meme_record = parser.parse(f) for motif in meme_record.motifs: for instance in motif.instances: print instance.motif_name, instance.sequence_name, instance.strand, instance.pvalue ''' |