Reading Ab1 Files With Python
3
4
Entering edit mode
14.2 years ago
bow ▴ 790

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 • 20k views
ADD COMMENT
0
Entering edit mode

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

ADD REPLY
0
Entering edit mode

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 REPLY
0
Entering edit mode
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 REPLY
6
Entering edit mode
14.2 years ago
Will 4.6k

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 COMMENT
0
Entering edit mode

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 REPLY
0
Entering edit mode

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 REPLY
0
Entering edit mode

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

ADD REPLY
0
Entering edit mode

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 REPLY
0
Entering edit mode

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

ADD REPLY
0
Entering edit mode

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

ADD REPLY
1
Entering edit mode
13.8 years ago
Ketil 4.1k

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 COMMENT
1
Entering edit mode
11.6 years ago
pstragier ▴ 10

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 COMMENT
0
Entering edit mode

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 REPLY

Login before adding your answer.

Traffic: 1547 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6