Commits

David King  committed 4b3e9ae

The refindex parameter may now be given a species name instead, and need not be the reference species of the MAF file.

  • Participants
  • Parent commits f452c9d

Comments (0)

Files changed (1)

File scripts/maf_extract_chrom_ranges.py

 TODO: Combine with maf_extract_ranges, and possibly share some code with 
       maf_extract_ranges_indexed.
 
-usage: %prog interval_file refindex [options] < maf_file
+usage: %prog interval_file rename|refindex [options] < maf_file
    -m, --mincols=10: Minimum length (columns) required for alignment to be output
    -p, --prefix=PREFIX: Prefix
 """
 
     try:
         range_filename = args[ 0 ]
-        refindex = int( args[ 1 ] )
+        try: 
+            refindex = int( args[ 1 ] )
+            refname = None
+        except: 
+            refindex = None
+            refname = args[ 1 ]
         if options.mincols: mincols = int( options.mincols )
         else: mincols = 10
         if options.prefix: prefix = options.prefix
     # Iterate over input MAF
 
     for maf in bx.align.maf.Reader( sys.stdin ):
+        if refname: 
+            sourcenames = [ cmp.src.split('.')[0] for cmp in maf.components ]
+            try: refindex = sourcenames.index( refname )
+            except:
+                continue
+
         ref_component = maf.components[ refindex ]
         # Find overlap with reference component
         if not ( ref_component.src in intersecters ): continue