Question: Reading Ab1 Files With Python
4
gravatar for bow
9.2 years ago by
bow790
Netherlands
bow790 wrote:

I'm looking for a way to convert a batch of AB1 trace files into FASTA using python. I've tried looking in the BioPython website but failed to find any reference on how to do it so far. For Perl folks, I know there might be a way to it with Bioperl, but as I'm much more familiar with Python, I prefer to do it that way.

So, any pointers? Help is much appreciated :)!

EDIT: Just as an additional info for people who might stumble on this page, I had some extra time for myself and decided to write a Python module for reading AB1 files. You can find it here.

python conversion • 10k views
ADD COMMENTlink modified 6.6 years ago by pstragier10 • written 9.2 years ago by bow790

was that enough of an answer? ... if so please mark a correct answer to help people who come on this question later :)

ADD REPLYlink written 9.2 years ago by Will4.5k

Bow donated his code to Biopython, and it is included with Biopython 1.58 onwards, see http://news.open-bio.org/news/2011/08/biopython-1-58-released/

Thanks!

ADD REPLYlink modified 8 weeks ago by RamRS24k • written 8.0 years ago by Peter5.8k
from Bio import SeqIO
handle = open("test.ab1", "rb")
for record in SeqIO.parse(handle, "abi"):
    print(record)
#from here on, you can extract the data and go to any file format you want.
ADD REPLYlink modified 8 weeks ago by RamRS24k • written 6.6 years ago by pstragier10
6
gravatar for Will
9.2 years ago by
Will4.5k
United States
Will4.5k wrote:

I had this same issue not too long ago: Converting Ab1 Trace Files Into Scf Trace Files

I couldn't find a reasonable python method so I ended up using Staden ... the docs are here

You could certainly use python's submodules to do it but convert_trace has a "directory" option to process everything in a directory.

Hope that helps,
Will

PS. I also tried abiparser.py (available by google-search) but that turned out to be a waste of ~3 hours trying to get it to work.

ADD COMMENTlink modified 8 weeks ago by RamRS24k • written 9.2 years ago by Will4.5k

Ah yes, I tried abiparser.py and it's a pain to understand :/. Staden isn't a walk in the park, too. I haven't been able to install it on Lucid. Probably you have some pointers on how to do it?

ADD REPLYlink written 9.2 years ago by bow790

actually its available from the Package Repository ... Its under bio-linux-staden, staden-io-lib-utils ... That's how I got it installed on my Lucid system

ADD REPLYlink written 9.2 years ago by Will4.5k

Is it from the official repo? I could install 'staden-io-lib-utils but not 'bio-linux-staden

ADD REPLYlink written 9.2 years ago by bow790

bio-linux-staden is from the Bio-Linux repository, which has lots of useful packages. Add deb http://nebc.nox.ac.uk/bio-linux/ unstable bio-linux to your /etc/apt/sources.list and do an apt-get update.

ADD REPLYlink modified 8 weeks ago by RamRS24k • written 9.2 years ago by Brad Chapman9.5k

Thanks Brad, I always forget that I added the BioLnux repository

ADD REPLYlink written 9.2 years ago by Will4.5k

Thanks guys :)! I think I got it working now. I ended up making a bash script to iterate through the ab1 files.

ADD REPLYlink written 9.2 years ago by bow790
1
gravatar for Ketil
8.7 years ago by
Ketil4.0k
Germany
Ketil4.0k wrote:

I've always converted to Fasta (and qual) with Phred. Don't know how it compares to Staden, but at least with old equipment, you don't want to extract just the sequence data embedded in the trace file, as Phred does (did?) a better job.

There are other options, TraceTuner and PeakTrace, I don't know how well they fare.

ADD COMMENTlink written 8.7 years ago by Ketil4.0k
1
gravatar for pstragier
6.6 years ago by
pstragier10
pstragier10 wrote:

Using Biopython:

from Bio import SeqIO
handle = open("test.ab1", "rb")
for record in SeqIO.parse(handle, "abi"):
    print(record)

From here on, you can extract the data and go to any file format you want.

ADD COMMENTlink modified 10 weeks ago by RamRS24k • written 6.6 years ago by pstragier10

The code Biopython uses to read ABI files was contributed by Bow himself (after this question was written). See the comments on the question itself.

ADD REPLYlink written 6.6 years ago by Peter5.8k
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1652 users visited in the last hour