Bug fix in subtract_query1, made CustomTrack.sniff() more restrictive.

This commit is contained in:
Greg Von Kuster
2007-10-30 13:28:24 +00:00
parent 575d2d2ffb
commit 518a2d66a8
2 changed files with 17 additions and 20 deletions
+8 -15
View File
@@ -714,23 +714,16 @@ class CustomTrack ( Tabular ):
for hdr in headers:
if first_line:
try:
if hdr[0].startswith('track'):
first_line = False
else:
return False
except:
return False
if hdr[0].startswith('track') and hdr[0].find('color') > -1 and hdr[0].find('visibility') > -1: first_line = False
else: return False
except: return False
else:
try:
if not (hdr[0] == '' or hdr[0].startswith( '#' )):
if len(hdr) < 3:
return False
try:
map( int, [hdr[1], hdr[2]] )
except:
return False
except:
return False
if hdr[0] and not hdr[0].startswith( '#' ):
if len( hdr ) < 3: return False
try: map( int, [hdr[1], hdr[2]] )
except: return False
except: return False
return True
class GBrowseTrack ( Tabular ):
+9 -5
View File
@@ -18,12 +18,16 @@ def get_lines(fname, begin_col='', end_col=''):
i = 0
for i, line in enumerate(file(fname)):
line = line.rstrip('\r\n')
if line != '' and not line.startswith('#'):
if line and not line.startswith('#'):
if begin_col and end_col:
"""Both begin_col and end_col must be integers at this point."""
line = line.split('\t')
line = '\t'.join([line[j] for j in range(begin_col-1, end_col)])
lines.add( line )
try:
line = line.split('\t')
line = '\t'.join([line[j] for j in range(begin_col-1, end_col)])
lines.add( line )
except: pass
else:
lines.add( line )
if i: return (i+1, lines)
else: return (i, lines)
@@ -89,7 +93,7 @@ def main():
info_msg += 'Restricted to columns c' + str(begin_col) + ' thru c' + str(end_col) + '. '
if diff1 > 0:
info_msg += 'Eliminated %d duplicate/blank/comment lines from first query.' %diff1
info_msg += 'Eliminated %d duplicate/blank/comment/invalid lines from first query.' %diff1
print info_msg