Biopython (一)安装与介绍

被朋友安利一个专门用于处理生物信息学的工具箱“Biopython”,别人用python开发的小工具直接拿来用用也是很省时省力的,好吧,学生信就从“调包侠”开始做起吧!

因为刚好有“需求”:用biopython的bcbio-gff来实现gbff文件转gff,所以就拿这个小功能来试一下biopython。
方法参考:https://www.jianshu.com/p/152efcfabf0f?from=singlemessage

那么,先从biopython的安装开始吧

官网:https://biopython.org/

Tutorial:http://biopython.org/DIST/docs/tutorial/Tutorial.html#sec5

GitHub:https://github.com/biopython/biopython

中文说明书:https://biopython-cn.readthedocs.io/zh_CN/latest/cn/chr01.html

最简单的安装方式就是用pip:


pip install biopython

如果需要更新版本的话:


pip install biopython --upgrade

安装新版本之前如果卸载旧版本或者卸载biopython:


pip uninstall biopython

Biopython不同版本适用于不同的python版本,Biopython 1.68 was our final release to support Python 2.6, while Biopython 1.76 was our final release to support Python 2.7 and Python 3.5。biopython以前的版本在pypi里面有,或者官网,因此,如果要在特定的python版本里安装biopython就要用:


python3.6 -m pip install biopython

pypy -m pip install biopython

## 如果python3像我的一样用conda安装的,可以先激活python3环境再安装,我的python版本是3.7.8

conda activate python3

python -m pip install biopython

## 或直接pip install biopython,都是安装在python3环境里的site-packages里##

一般来说需要进行按照附带的README文件从源开始安装,以确保安装的没有问题。事实上也可以跳过build和test,直接install。


python setup.py build 

python setup.py test 

sudo python setup.py install

查看biopython版本,进入python3,然后:


>>> import Bio

>>> print(Bio.__version__)

...

这里需要用到biopython里的工具SeqIO(序列的输入和输出),

先安装bcbio-gff:


pip install bcbio-gff

然后写一个调用工具python小脚本gbff2gff.py,参考 Parsing GFF Files · Biopython :


#!/usr/bin/env python3

# -*- coding: utf-8 -*-

from BCBio import GFF

from Bio import SeqIO

import sys

inputfile, outfile = sys.argv[1:3]

in_file = inputfile

out_file = outfile

in_handle = open(in_file)

out_handle = open(out_file, "w")

GFF.write(SeqIO.parse(in_handle, "genbank"), out_handle)

in_handle.close()

out_handle.close()

例如运行:


python gbff2gff.py GCA_008086715.1_ASM808671v1_genomic.gbff GCA_008086715.1_ASM808671v1_genomic.gff

就完成了一个小练习。


引用原文链接:https://www.jianshu.com/p/152efcfabf0f?from=singlemessage

如有任何侵权问题请联系本人:[email protected]

你可能感兴趣的:(Biopython (一)安装与介绍)