Changeset 1476:77f8bf51b2ae

Show
Ignore:
Timestamp:
08/22/08 10:39:58 (3 months ago)
Author:
Greg Von Kuster <greg@bx.psu.edu>
branch:
default
Message:

Better fix for interval_maf_to_merged_fasta when no strand column in input, added functional test.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • tools/maf/interval_maf_to_merged_fasta.py

    r1472 r1476  
    3434assert sys.version_info[:2] >= ( 2, 4 ) 
    3535 
     36def stop_err( msg ): 
     37    sys.stderr.write( msg ) 
     38    sys.exit() 
     39 
    3640def __main__(): 
    3741     
     
    3943    options, args = doc_optparse.parse( __doc__ ) 
    4044    mincols = 0 
    41      
    42     if options.dbkey: primary_species = options.dbkey 
    43     else: primary_species = None 
     45    strand_col = -1 
     46    
     47    if options.dbkey: 
     48        primary_species = options.dbkey 
     49    else: 
     50        primary_species = None 
    4451    if primary_species in [None, "?", "None"]: 
    45         print >>sys.stderr, "You must specify a proper build in order to extract alignments. You can specify your genome build by clicking on the pencil icon associated with your interval file." 
    46         sys.exit() 
     52        stop_err( "You must specify a proper build in order to extract alignments. You can specify your genome build by clicking on the pencil icon associated with your interval file." ) 
    4753     
    4854    include_primary = True 
     
    5359            species = None 
    5460        else: 
    55             try: secondary_species.remove( primary_species ) 
    56             except: include_primary = False 
     61            try: 
     62                secondary_species.remove( primary_species ) 
     63            except: 
     64                include_primary = False 
    5765            species = [primary_species] + secondary_species 
    5866     
    59     if options.interval_file: interval_file = options.interval_file 
     67    if options.interval_file: 
     68        interval_file = options.interval_file 
    6069    else:  
    61         print >>sys.stderr, "Input interval file has not been specified." 
    62         sys.exit() 
     70        stop_err( "Input interval file has not been specified." ) 
    6371     
    64     if options.output_file: output_file = options.output_file 
     72    if options.output_file: 
     73        output_file = options.output_file 
    6574    else:  
    66         print >>sys.stderr, "Output file has not been specified." 
    67         sys.exit() 
     75        stop_err( "Output file has not been specified." ) 
    6876     
    6977    if not options.geneBED: 
     
    7179            chr_col = int( options.chromCol ) - 1 
    7280        else:  
    73             print >>sys.stderr, "Chromosome column not set, click the pencil icon in the history item to set the metadata attributes." 
    74             sys.exit() 
     81            stop_err( "Chromosome column not set, click the pencil icon in the history item to set the metadata attributes." ) 
    7582         
    7683        if options.startCol: 
    7784            start_col = int( options.startCol ) - 1 
    7885        else:  
    79             print >>sys.stderr, "Start column not set, click the pencil icon in the history item to set the metadata attributes." 
    80             sys.exit() 
     86            stop_err( "Start column not set, click the pencil icon in the history item to set the metadata attributes." ) 
    8187         
    8288        if options.endCol: 
    8389            end_col = int( options.endCol ) - 1 
    8490        else:  
    85             print >>sys.stderr, "End column not set, click the pencil icon in the history item to set the metadata attributes." 
    86             sys.exit() 
    87          
     91            stop_err( "End column not set, click the pencil icon in the history item to set the metadata attributes." ) 
     92 
    8893        if options.strandCol: 
    8994            strand_col = int( options.strandCol ) - 1 
    90         else:  
    91             strandCol = -1 
    9295 
    9396    mafIndexFile = "%s/maf_index.loc" % options.mafIndexFileDir 
     
    100103        index = maf_utilities.maf_index_by_uid( options.mafSource, mafIndexFile ) 
    101104        if index is None: 
    102             print >> sys.stderr, "The MAF source specified (%s) appears to be invalid." % ( options.mafSource ) 
    103             sys.exit() 
     105            stop_err( "The MAF source specified (%s) appears to be invalid." % ( options.mafSource ) ) 
    104106    elif options.mafSourceType.lower() in ["user"]: 
    105107        #index maf for use here, need to remove index_file when finished 
    106108        index, index_filename = maf_utilities.build_maf_index( options.mafSource, species = [primary_species] ) 
    107109        if index is None: 
    108             print >> sys.stderr, "Your MAF file appears to be malformed." 
    109             sys.exit() 
     110            stop_err( "Your MAF file appears to be malformed." ) 
    110111    else: 
    111         print >> sys.stderr, "Invalid MAF source type specified." 
    112         sys.exit() 
     112        stop_err( "Invalid MAF source type specified." ) 
    113113     
    114114    #open output file 
    115115    output = open( output_file, "w" ) 
    116      
    117116     
    118117    if options.geneBED: 
  • tools/maf/interval_maf_to_merged_fasta.xml

    r1451 r1476  
    5757  <tests> 
    5858    <test> 
     59      <param name="input1" value="13.bed" dbkey="hg18" ftype="bed"/> 
     60      <param name="maf_source" value="cached"/> 
     61      <param name="maf_identifier" value="17_WAY_MULTIZ_hg18"/> 
     62      <param name="species" value="hg18,mm8"/> 
     63      <output name="out_file1" file="interval_maf_to_merged_fasta_out3.fasta" /> 
     64    </test> 
     65    <test> 
    5966      <param name="input1" value="1.bed" dbkey="hg17" ftype="bed"/> 
    6067      <param name="maf_source" value="cached"/>