Mercurial > repos > cpt > cpt_sar_finder
comparison biopython_parsing.py @ 1:112751823323 draft
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
author | cpt |
---|---|
date | Mon, 05 Jun 2023 02:52:57 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
0:9f62910edcc9 | 1:112751823323 |
---|---|
1 #!/usr/bin/env python | |
2 # Biopython parsing module. Uses in conjunction with the sar_finder script, and potential future scripts down the line. | |
3 | |
4 from Bio import SeqIO | |
5 | |
6 | |
7 class FASTA_parser: | |
8 """Parses multi fasta file, and zips together header with sequence""" | |
9 | |
10 def __init__(self, fa): | |
11 self.fa = fa | |
12 | |
13 def multifasta_dict(self): | |
14 """parses the input multi fasta, and puts results into dictionary""" | |
15 | |
16 return SeqIO.to_dict(SeqIO.parse(self.fa, "fasta")) | |
17 | |
18 | |
19 if __name__ == "__main__": | |
20 fa_file = "test-data/mu-proteins.fa" | |
21 d = FASTA_parser(fa_file).multifasta_dict() | |
22 print(d) | |
23 for k, v in d.items(): | |
24 print(v.description) |