def setUp(self): test_file = os.path.join('NeuralNetwork', 'enolase.fasta') diff_file = os.path.join('NeuralNetwork', 'repeat.fasta') self.test_records = [] self.diff_records = [] # load the records for file, records in ((test_file, self.test_records), (diff_file, self.diff_records)): handle = open(file, 'r') iterator = SeqIO.parse(handle, "fasta", alphabet=IUPAC.unambiguous_dna) while 1: try: seq_record = next(iterator) except StopIteration: break if seq_record is None: break records.append(seq_record) handle.close() self.motif_finder = Motif.MotifFinder()
def _load_schema_repository(self): """Helper function to load a schema repository from a file. This also caches a schema bank, to prevent having to do this time consuming operation multiple times. """ # if we already have a cached repository, return it if self.schema_bank is not None: return self.schema_bank # otherwise, we'll read in a new schema bank # read in the all of the motif records motif_handle = open(self.test_file, 'r') seq_records = list( SeqIO.parse(motif_handle, "fasta", alphabet=IUPAC.unambiguous_dna)) motif_handle.close() # find motifs from the file motif_finder = Motif.MotifFinder() motif_size = 9 motif_bank = motif_finder.find(seq_records, motif_size) schema_bank = self.factory.from_motifs(motif_bank, .1, 2) # cache the repository self.schema_bank = schema_bank return schema_bank
def setUp(self): test_file = os.path.join('NeuralNetwork', 'enolase.fasta') diff_file = os.path.join('NeuralNetwork', 'repeat.fasta') self.test_records = [] self.diff_records = [] # load the records for file, records in ((test_file, self.test_records), (diff_file, self.diff_records)): handle = open(file, 'r') seq_parser = Fasta.SequenceParser(alphabet=IUPAC.unambiguous_dna) iterator = Fasta.Iterator(handle, seq_parser) while 1: seq_record = iterator.next() if seq_record is None: break records.append(seq_record) handle.close() self.motif_finder = Motif.MotifFinder()