- 论坛徽章:
- 6
|
使用biopython的确很简单呐
你参考一下吧
- [root@CentOS ~]# pip install biopython
- You are using pip version 7.1.0, however version 7.1.2 is available.
- You should consider upgrading via the 'pip install --upgrade pip' command.
- Collecting biopython
- Downloading biopython-1.66.tar.gz (13.7MB)
- 100% |████████████████████████████████| 13.7MB 1.5kB/s
- Installing collected packages: biopython
- Running setup.py install for biopython
- Successfully installed biopython-1.66
- [root@CentOS ~]#
- >>> from Bio import SeqIO
- >>> data = {}
- >>> with open("test.txt") as f:
- ... for seq in SeqIO.parse(f, "fasta"):
- ... print seq.id
- ... print repr(seq.seq)
- ... data[seq.id] = str(seq.seq)
- ...
- chr1|hos107.1
- Seq('ACACTCCCGGGCCCCCCCCCCCCACCTTTCAAAAAAAAAAAAAAAAATTTTCCC...GGG', SingleLetterAlphabet())
- chr1|hos107.2
- Seq('ACACTCCCGGGCCCCCCCCCCCCACCTTTCAAAAAAAAAAAAAAAAATTTTC', SingleLetterAlphabet())
- >>> print data
- {'chr1|hos107.1': 'ACACTCCCGGGCCCCCCCCCCCCACCTTTCAAAAAAAAAAAAAAAAATTTTCCCCCCAAAGGGG', 'chr1|hos107.2': 'ACACTCCCGGGCCCCCCCCCCCCACCTTTCAAAAAAAAAAAAAAAAATTTTC'}
- >>>
复制代码 |
|