Changeset 1476:77f8bf51b2ae
- 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
| r1472 |
r1476 |
|
| 34 | 34 | assert sys.version_info[:2] >= ( 2, 4 ) |
|---|
| 35 | 35 | |
|---|
| | 36 | def stop_err( msg ): |
|---|
| | 37 | sys.stderr.write( msg ) |
|---|
| | 38 | sys.exit() |
|---|
| | 39 | |
|---|
| 36 | 40 | def __main__(): |
|---|
| 37 | 41 | |
|---|
| … | … | |
| 39 | 43 | options, args = doc_optparse.parse( __doc__ ) |
|---|
| 40 | 44 | 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 |
|---|
| 44 | 51 | 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." ) |
|---|
| 47 | 53 | |
|---|
| 48 | 54 | include_primary = True |
|---|
| … | … | |
| 53 | 59 | species = None |
|---|
| 54 | 60 | 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 |
|---|
| 57 | 65 | species = [primary_species] + secondary_species |
|---|
| 58 | 66 | |
|---|
| 59 | | if options.interval_file: interval_file = options.interval_file |
|---|
| | 67 | if options.interval_file: |
|---|
| | 68 | interval_file = options.interval_file |
|---|
| 60 | 69 | 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." ) |
|---|
| 63 | 71 | |
|---|
| 64 | | if options.output_file: output_file = options.output_file |
|---|
| | 72 | if options.output_file: |
|---|
| | 73 | output_file = options.output_file |
|---|
| 65 | 74 | else: |
|---|
| 66 | | print >>sys.stderr, "Output file has not been specified." |
|---|
| 67 | | sys.exit() |
|---|
| | 75 | stop_err( "Output file has not been specified." ) |
|---|
| 68 | 76 | |
|---|
| 69 | 77 | if not options.geneBED: |
|---|
| … | … | |
| 71 | 79 | chr_col = int( options.chromCol ) - 1 |
|---|
| 72 | 80 | 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." ) |
|---|
| 75 | 82 | |
|---|
| 76 | 83 | if options.startCol: |
|---|
| 77 | 84 | start_col = int( options.startCol ) - 1 |
|---|
| 78 | 85 | 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." ) |
|---|
| 81 | 87 | |
|---|
| 82 | 88 | if options.endCol: |
|---|
| 83 | 89 | end_col = int( options.endCol ) - 1 |
|---|
| 84 | 90 | 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 | |
|---|
| 88 | 93 | if options.strandCol: |
|---|
| 89 | 94 | strand_col = int( options.strandCol ) - 1 |
|---|
| 90 | | else: |
|---|
| 91 | | strandCol = -1 |
|---|
| 92 | 95 | |
|---|
| 93 | 96 | mafIndexFile = "%s/maf_index.loc" % options.mafIndexFileDir |
|---|
| … | … | |
| 100 | 103 | index = maf_utilities.maf_index_by_uid( options.mafSource, mafIndexFile ) |
|---|
| 101 | 104 | 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 ) ) |
|---|
| 104 | 106 | elif options.mafSourceType.lower() in ["user"]: |
|---|
| 105 | 107 | #index maf for use here, need to remove index_file when finished |
|---|
| 106 | 108 | index, index_filename = maf_utilities.build_maf_index( options.mafSource, species = [primary_species] ) |
|---|
| 107 | 109 | 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." ) |
|---|
| 110 | 111 | else: |
|---|
| 111 | | print >> sys.stderr, "Invalid MAF source type specified." |
|---|
| 112 | | sys.exit() |
|---|
| | 112 | stop_err( "Invalid MAF source type specified." ) |
|---|
| 113 | 113 | |
|---|
| 114 | 114 | #open output file |
|---|
| 115 | 115 | output = open( output_file, "w" ) |
|---|
| 116 | | |
|---|
| 117 | 116 | |
|---|
| 118 | 117 | if options.geneBED: |
|---|
| r1451 |
r1476 |
|
| 57 | 57 | <tests> |
|---|
| 58 | 58 | <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> |
|---|
| 59 | 66 | <param name="input1" value="1.bed" dbkey="hg17" ftype="bed"/> |
|---|
| 60 | 67 | <param name="maf_source" value="cached"/> |
|---|