This is a test version of Biostars. For the public version, visit https://www.biostars.org.
How Do I Read A Maf File From File Into Pygr

I have looked through the manual and it seems to concentrate a lot on using data from an online database, but I could find anything about reading MAF files locally. I suspect it might involve the NLMSA class, but I'm not sure.

2 answers

I use bx-python for that: https://bitbucket.org/james_taylor/bx-python/wiki/Home

import bx.align.maf
for alignment in bx.align.maf.Reader(open("alignment.maf")):
    print alignment.split()

alignment.split() now is a neat list in the "line starting with s"-format (http://genome.ucsc.edu/FAQ/FAQformat.html#format5) where you can parse out all relevant info you might need.

This turned out to be a good option. I will approve it.

There is a MAF parser in the pygr package: http://biodb.bioinformatics.ucla.edu/pygr_docs/0.8.1/html/epydoc/pygr.apps.maf2VSgraph.MafParser-class.html have you looked at that already?

Yes. As far as I can tell, that's a helper function and not intended to be used directly.

Log in to answer this question.