def read(self,input_file,trim=None):
# load file to a parser
fasta_sequences = SeqIO.parse(open(input_file),'fasta')
if(trim==None):
# if there is nothing to trim from
# parse sequences as they are
# by storing name and sequence as
# string
for fasta in fasta_sequences:
name, sequence = fasta.id, str(fasta.seq)
self._sequence_dictionary[name] = sequence
else:
# if there is sothing to trim from
# parse sequences as they are but when holding sequence name
# as dictionary key trim as suggested
for fasta in fasta_sequences:
name, sequence = fasta.id, str(fasta.seq)
self._sequence_dictionary[name.strip(str(trim))] = sequence
# method that returns the sequence dictionary
评论列表
文章目录