Files
galaxy/tools/maf/maf_reverse_complement.py
T
Daniel Blankenberg 5b1552ffa8 Fix memory issues when dealing with MAF tools.
Add new bx-python eggs.

Reorganize all MAF tools into a unified directory, and update tool_conf.

Remember to update tool_conf.xml from one of the samples (tool_conf.xml.sample or tool_conf.xml.main).
2008-01-16 18:01:09 +00:00

35 lines
994 B
Python

#!/usr/bin/env python2.4
"""
Reads a MAF file. Produces a MAF file containing
the reverse complement for each block in the source file.
usage: %prog input_maf_file output_maf_file
"""
#Dan Blankenberg
import pkg_resources; pkg_resources.require( "bx-python" )
import bx.align.maf
import sys
def __main__():
#Parse Command Line
input_file = sys.argv.pop( 1 )
output_file = sys.argv.pop( 1 )
try:
maf_writer = bx.align.maf.Writer( open( output_file, 'w' ) )
except:
print sys.stderr, "Unable to open output file"
sys.exit()
try:
count = 0
for count, maf in enumerate( bx.align.maf.Reader( open( input_file ) ) ):
maf_writer.write( maf.reverse_complement() )
except:
print >>sys.stderr, "Your MAF file appears to be malformed."
sys.exit()
print "%i regions were reverse complemented." % count
maf_writer.close()
if __name__ == "__main__": __main__()