Files
galaxy/tools/maf/maf_reverse_complement.py
T
Daniel Blankenberg 377c2427a7 Allow workflows that contain tools that had parameters added to them after the workflow was created to be edited. Workflows containing tools with added parameters can still not be run until after they are edited and saved. Default values are provided in the workflow building mode.
Allow most MAF tools to allow limiting of output species. MAF tools which do not allow species limiting include Extract Pairwise MAF blocks, MAF Coverage stats, and Filter MAF blocks by Size.

The functionality of Filter MAF blocks by Species and Filter MAF blocks by Size is now available in Filter MAF by specified attributes. Unfortunately tests are still not able to be written for the Filter MAF by specified attributes tool.
2009-02-04 14:55:45 -05:00

43 lines
1.2 KiB
Python

#!/usr/bin/env python
"""
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
from galaxy import eggs
import pkg_resources; pkg_resources.require( "bx-python" )
import bx.align.maf
from galaxy.tools.util import maf_utilities
import sys
assert sys.version_info[:2] >= ( 2, 4 )
def __main__():
#Parse Command Line
input_file = sys.argv.pop( 1 )
output_file = sys.argv.pop( 1 )
species = maf_utilities.parse_species_option( 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 = maf.reverse_complement()
if species:
maf = maf.limit_to_species( species )
maf_writer.write( maf )
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__()