Code to work with Genbank files
Project description
genbank
Python code to work with Genbank files
This repo contains several classes to help work with Genbank files
The flow goes:
File -> Locus -> Feature
To use:
from genbank.file import File
file = File('infile.gbk')
for locus in file:
print(name)
for feature in locus:
print(feature)
You can also build a Locus object from the ground up:
from genbank.locus import Locus
locus = Locus('test', 'actgactgatcgtagctagc')
# then add a feature by parsing text of a genbank feature
locus.read_feature(' CDS 1..10')
# or add one by manually specifing the type,strand,and locations
locus.add_feature('CDS',+1,[['10','20']])
locus.write()
which gives:
LOCUS test 20 bp DNA UNK
DEFINITION test
FEATURES Location/Qualifiers
CDS 1..10
CDS 10..20
ORIGIN
1 actgactgat cgtagctagc
//
This package also allows you to perform various conversions on a given genome file:
$ genbank.py tests/phiX174.gbk -f tabular
'phiX174' 'CDS' (('100', '627'),) {'gene': "G"}
'phiX174' 'CDS' (('636', '1622'),) {'gene': "H"}
'phiX174' 'CDS' (('1659', '3227'),) {'gene': "A"}
'phiX174' 'CDS' (('2780', '3142'),) {'gene': "B"}
'phiX174' 'CDS' (('3142', '3312'),) {'gene': "K"}
$ genbank.py tests/phiX174.gbk -f fasta
>phiX174
gtgtgaggttataacgccgaagcggtaaaaattttaatttttgccgctgagggg
ttgaccaagcgaagcgcggtaggttttctgcttaggagtttaatcatgtttcag
$ genbank.py tests/phiX174.gbk -f fna
>phiX174_CDS_[100..627] [gene="G"]
atgtttcagacttttatttctcgccataattcaaactttttttctgataag
>phiX174_CDS_[636..1622] [gene="H"]
atgtttggtgctattgctggcggtattgcttctgctcttgctggtggcgcc
>phiX174_CDS_[1659..3227]
$ genbank.py tests/phiX174.gbk -f faa
>phiX174_CDS_[100..627] [gene="G"]
MFQTFISRHNSNFFSDKLVLTSVTPASSAPVLQTPKATSSTLYFDSLTVNA
>phiX174_CDS_[636..1622] [gene="H"]
MFGAIAGGIASALAGGAMSKLFGGGQKAASGGIQGDVLATDNNTVGMGDAG
>phiX174_CDS_[1659..3227] [gene="A"]
$ genbank.py tests/phiX174.gbk -f coverage
phiX174 0.965
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
genbank-0.38.tar.gz
(24.8 kB
view details)
Built Distribution
genbank-0.38-py3-none-any.whl
(25.1 kB
view details)
File details
Details for the file genbank-0.38.tar.gz
.
File metadata
- Download URL: genbank-0.38.tar.gz
- Upload date:
- Size: 24.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.8.1 requests/2.21.0 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.8.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0504387ad3a7abea587b82e4d96817664d7f061bcf6a266450fe8d35beafed75 |
|
MD5 | 693fb41643c7025276395f520a2c1552 |
|
BLAKE2b-256 | 8ec90aa80bfa335f9159cb876c92b71a20a75d3ee0eb6353f181aa211528ba5e |
File details
Details for the file genbank-0.38-py3-none-any.whl
.
File metadata
- Download URL: genbank-0.38-py3-none-any.whl
- Upload date:
- Size: 25.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.8.1 requests/2.21.0 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.8.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | dcc5717f572c4cd98fcaecd6bcc2676fcab39d238b8e5ef5a8d6eaf6565bf3fb |
|
MD5 | f72890173c7a07ad8c2cdd5c176818ff |
|
BLAKE2b-256 | c97046c597787bbfe5c16e53fead9195747d6321d9d7a7b36e7fb387190fd702 |