Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modernize exception handling for devteam tools #584

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions tool_collections/taxonomy/find_diag_hits/find_diag_hits.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ def stop_err(msg):
val_string = val_string.strip(', ')
val_string = "insert into tax values(" + val_string + ")"
cur.execute(val_string)
except Exception, e:
except Exception as e:
stop_err('%s\n' % e)

tax_file.close()
Expand Down Expand Up @@ -165,6 +165,6 @@ def stop_err(msg):
out_string = '%s\t%s\t' % ( item[0], item[1] )
out_string += rankName
print >>out_file, out_string
except Exception, e:
except Exception as e:
stop_err("%s\n" % e)

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<tool id="find_diag_hits" name="Find diagnostic hits" version="1.0.0">
<tool id="find_diag_hits" name="Find diagnostic hits" version="1.0.1">
<description></description>
<requirements>
<requirement type="package" version="1.0.0">taxonomy</requirement>
Expand Down
4 changes: 2 additions & 2 deletions tool_collections/taxonomy/lca_wrapper/lca.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class :10,
if POS2 is not specified, the newer versions of sort will consider the entire line for sorting. To prevent this, we set POS2=POS1.
"""
command_line = "sort -f -k " + str(group_col+1) +"," + str(group_col+1) + " -o " + tmpfile.name + " " + inputfile
except Exception, exc:
except Exception as exc:
stop_err( 'Initialization error -> %s' %str(exc) )

error_code, stdout = commands.getstatusoutput(command_line)
Expand Down Expand Up @@ -190,4 +190,4 @@ class :10,
print "Skipped %d invalid lines." % ( skipped_lines )

if __name__ == "__main__":
main()
main()
2 changes: 1 addition & 1 deletion tool_collections/taxonomy/lca_wrapper/lca.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<tool id="lca1" name="Find lowest diagnostic rank" version="1.0.1">
<tool id="lca1" name="Find lowest diagnostic rank" version="1.0.2">
<description></description>
<requirements>
<requirement type="package" version="1.0.0">taxonomy</requirement>
Expand Down
Binary file removed tool_collections/taxonomy/t2ps/t2ps.tgz
Binary file not shown.
6 changes: 3 additions & 3 deletions tool_collections/taxonomy/t2ps/t2ps_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def stop_err(msg):
retcode = subprocess.call( t2t_cmd, shell=True )
if retcode < 0:
print >>sys.stderr, "Execution of taxonomy2tree terminated by signal", -retcode
except OSError, e:
except OSError as e:
print >>sys.stderr, "Execution of taxonomy2tree failed:", e


Expand All @@ -53,7 +53,7 @@ def stop_err(msg):
retcode = subprocess.call( t2ps_cmd, shell=True )
if retcode < 0:
print >>sys.stderr, "Execution of tree2PS-fast terminated by signal", -retcode
except OSError, e:
except OSError as e:
print >>sys.stderr, "Execution of tree2PS-fast failed:", e

# Convert PS to PDF
Expand All @@ -63,5 +63,5 @@ def stop_err(msg):
retcode = subprocess.call( ps2pdf_cmd, shell=True )
if retcode < 0:
print >>sys.stderr, "Execution of ps2pdf terminated by signal", -retcode
except OSError, e:
except OSError as e:
print >>sys.stderr, "Execution of ps2pdf failed:", e
2 changes: 1 addition & 1 deletion tool_collections/taxonomy/t2ps/t2ps_wrapper.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<tool id="Draw_phylogram" name="Draw phylogeny" version="1.0.0">
<tool id="Draw_phylogram" name="Draw phylogeny" version="1.0.1">
<description></description>
<requirements>
<requirement type="package" version="1.0.0">taxonomy</requirement>
Expand Down
2 changes: 1 addition & 1 deletion tools/annotation_profiler/annotation_profiler.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<tool id="Annotation_Profiler_0" name="Profile Annotations" version="1.0.0">
<tool id="Annotation_Profiler_0" name="Profile Annotations" version="1.0.1">
<description>for a set of genomic intervals</description>
<requirements>
<requirement type="package" version="0.7.1">bx-python</requirement>
Expand Down
6 changes: 3 additions & 3 deletions tools/annotation_profiler/annotation_profiler_for_interval.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def __getitem__( self, i ):
try:
start = struct.unpack( self.fmt, self.file.read( self.fmt_size ) )[0]
end = struct.unpack( self.fmt, self.file.read( self.fmt_size ) )[0]
except Exception, e:
except Exception as e:
raise IndexError, e
self._cached_ranges[i] = ( start, end )
return start, end
Expand All @@ -45,12 +45,12 @@ class RegionCoverage:
def __init__( self, filename_base, profiler_info ):
try:
self._coverage = CachedRangesInFile( "%s.covered" % filename_base, profiler_info )
except Exception, e:
except Exception as e:
#print "Error loading coverage file %s: %s" % ( "%s.covered" % filename_base, e )
self._coverage = []
try:
self._total_coverage = int( open( "%s.total_coverage" % filename_base ).read() )
except Exception, e:
except Exception as e:
#print "Error loading total coverage file %s: %s" % ( "%s.total_coverage" % filename_base, e )
self._total_coverage = 0
def get_start_index( self, start ):
Expand Down
2 changes: 1 addition & 1 deletion tools/annotation_profiler/scripts/build_profile_indexes.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ def __main__():
chrom_lengths[ fields[0] ] = int( fields[ 1 ] )
chroms = chrom_lengths.keys()
print 'Chrom info taken from chromInfo.txt.gz.'
except Exception, e:
except Exception as e:
print 'Error loading chrom info from chromInfo.txt.gz, trying FTP method.'
chrom_lengths = {} #zero out chrom_lengths
chroms = []
Expand Down
6 changes: 0 additions & 6 deletions tools/annotation_profiler/tool_dependencies.xml

This file was deleted.

6 changes: 3 additions & 3 deletions tools/best_regression_subsets/best_regression_subsets.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@ def stop_err(msg):
fields = line.split("\t")
try:
yval = float(fields[y_col])
except Exception, ey:
except Exception as ey:
yval = r('NA')
y_vals.append(yval)
for k, col in enumerate(x_cols):
try:
xval = float(fields[col])
except Exception, ex:
except Exception as ex:
xval = r('NA')
x_vals[k].append(xval)
except:
Expand All @@ -65,7 +65,7 @@ def stop_err(msg):
set_default_mode(NO_CONVERSION)
try:
leaps = r.regsubsets(r("y ~ x"), data= r.na_exclude(dat))
except RException, rex:
except RException as rex:
stop_err("Error performing linear regression on the input data.\nEither the response column or one of the predictor columns contain no numeric values.")
set_default_mode(BASIC_CONVERSION)

Expand Down
2 changes: 1 addition & 1 deletion tools/best_regression_subsets/best_regression_subsets.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<tool id="BestSubsetsRegression1" name="Perform Best-subsets Regression" version="1.0.0">
<tool id="BestSubsetsRegression1" name="Perform Best-subsets Regression" version="1.0.1">
<description> </description>
<requirements>
<requirement type="package" version="1.7.1">numpy</requirement>
Expand Down
9 changes: 0 additions & 9 deletions tools/best_regression_subsets/tool_dependencies.xml

This file was deleted.

4 changes: 2 additions & 2 deletions tools/blat_coverage_report/blat_coverage_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def __main__():
if not diff_hash.has_key((chrom, cur_index)):
try:
diff_hash[(chrom, cur_index)] = [0,0,0,0,sub_b.upper()] # a, t, c, g, ref. nuc.
except Exception, e:
except Exception as e:
stop_err( str( e ) )
if sub_a in ['a','t','c','g']:
diff_hash[(chrom, cur_index)][nuc_index[(sub_a)]] += 1
Expand Down Expand Up @@ -104,4 +104,4 @@ def __main__():
if invalid_chars:
print 'Skipped %d invalid characters in the alignment. ' % (invalid_chars)

if __name__ == '__main__': __main__()
if __name__ == '__main__': __main__()
2 changes: 1 addition & 1 deletion tools/blat_coverage_report/blat_coverage_report.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<tool id="generate_coverage_report" name="Polymorphism of the Reads" version="1.0.0">
<tool id="generate_coverage_report" name="Polymorphism of the Reads" version="1.0.1">
<description>the percentage of reads supporting each nucleotide at each location</description>
<command interpreter="python">blat_coverage_report.py $input1 $output1</command>
<inputs>
Expand Down
4 changes: 2 additions & 2 deletions tools/canonical_correlation_analysis/cca.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def stop_err(msg):
ycolnames = ["c%d" %(el+1) for el in y_cols]
cc = r.cca(x=x_dat, y=y_dat, xlab=xcolnames, ylab=ycolnames, xcenter=r(x_center), ycenter=r(y_center), xscale=r(x_scale), yscale=r(y_scale), standardize_scores=r(std_scores))
ftest = r.F_test_cca(cc)
except RException, rex:
except RException as rex:
stop_err("Encountered error while performing CCA on the input data: %s" %(rex))

set_default_mode(BASIC_CONVERSION)
Expand Down Expand Up @@ -155,4 +155,4 @@ def stop_err(msg):
#r.plot(cc)
for i in range(ncomps):
r.helio_plot(cc, cv = i+1, main = r.paste("Explained Variance for CV",i+1), type = "variance")
r.dev_off()
r.dev_off()
4 changes: 2 additions & 2 deletions tools/canonical_correlation_analysis/cca.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<tool id="cca1" name="Canonical Correlation Analysis" version="1.0.0">
<tool id="cca1" name="Canonical Correlation Analysis" version="1.0.1">
<description> </description>
<requirements>
<requirement type="package" version="2.11.0">R</requirement>
davebx marked this conversation as resolved.
Show resolved Hide resolved
<requirement type="package" version="1.7.1">numpy</requirement>
<requirement type="package" version="1.0">yacca</requirement>
<requirement type="package" version="1.0">r-yacca</requirement>
<requirement type="package" version="1.0.3">rpy</requirement>
</requirements>
<command interpreter="python">
Expand Down
15 changes: 0 additions & 15 deletions tools/canonical_correlation_analysis/tool_dependencies.xml

This file was deleted.

2 changes: 1 addition & 1 deletion tools/ccat/ccat_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def main():
shutil.move( os.path.join( tmp_dir, "%s.significant.peak" % project_name ), output_peak_file )
shutil.move( os.path.join( tmp_dir, "%s.significant.region" % project_name ), output_region_file )
shutil.move( os.path.join( tmp_dir, "%s.top%i.peak" % ( project_name, output_num ) ), output_top_file )
except Exception, e:
except Exception as e:
return stop_err( tmp_dir, e )
os.rmdir( tmp_dir ) #clean up empty temp working directory

Expand Down
3 changes: 1 addition & 2 deletions tools/ccat/ccat_wrapper.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<tool id="peakcalling_ccat" name="CCAT" version="0.0.1">
<tool id="peakcalling_ccat" name="CCAT" version="0.0.2">
<description>Control-based ChIP-seq Analysis Tool</description>
<requirements>
<requirement type="package" version="3.0">CCAT</requirement>
<requirement type="package" version="3.0">ccat</requirement>
</requirements>
<command>
Expand Down
6 changes: 0 additions & 6 deletions tools/ccat/tool_dependencies.xml

This file was deleted.

2 changes: 1 addition & 1 deletion tools/correlation/cor.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def main():
# Run correlation
try:
value = r.cor( array( matrix ), use="pairwise.complete.obs", method=method )
except Exception, exc:
except Exception as exc:
out.close()
stop_err("%s" %str( exc ))
for row in value:
Expand Down
2 changes: 1 addition & 1 deletion tools/correlation/cor.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<tool id="cor2" name="Correlation" version="1.0.0">
<tool id="cor2" name="Correlation" version="1.0.1">
<description>for numeric columns</description>
<requirements>
<requirement type="package" version="1.0.3">rpy</requirement>
Expand Down
6 changes: 0 additions & 6 deletions tools/correlation/tool_dependencies.xml

This file was deleted.

2 changes: 1 addition & 1 deletion tools/featurecounter/featureCounter.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ def main():
out_file.write( "%s\n" % "\t".join( line.fields ) )
else:
out_file.write( "%s\n" % line )
except ParseError, exc:
except ParseError as exc:
out_file.close()
fail( str( exc ) )

Expand Down
2 changes: 1 addition & 1 deletion tools/featurecounter/featureCounter.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<tool id="featureCoverage1" name="Feature coverage" version="2.0.0">
<tool id="featureCoverage1" name="Feature coverage" version="2.0.1">
<description></description>
<requirements>
<requirement type="package" version="0.7.1">bx-python</requirement>
Expand Down
9 changes: 0 additions & 9 deletions tools/featurecounter/tool_dependencies.xml

This file was deleted.

2 changes: 1 addition & 1 deletion tools/getindelrates_3way/getIndelRates_3way.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ def main():
elif elems[1].endswith('delete'):
deletes[sp_ind] += 1
prev_bnum = new_bnum
except Exception, ei:
except Exception as ei:
#print >>sys.stderr, ei
continue
irate = []
Expand Down
2 changes: 1 addition & 1 deletion tools/getindelrates_3way/getIndelRates_3way.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<tool id="indelRates_3way" name="Estimate Indel Rates" version="1.0.0">
<tool id="indelRates_3way" name="Estimate Indel Rates" version="1.0.1">
<description> for 3-way alignments</description>
<requirements>
<requirement type="package" version="0.7.1">bx-python</requirement>
Expand Down
9 changes: 0 additions & 9 deletions tools/getindelrates_3way/tool_dependencies.xml

This file was deleted.

2 changes: 1 addition & 1 deletion tools/kernel_canonical_correlation_analysis/kcca.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ def stop_err(msg):

try:
kcc = r.kcca(x=x_dat, y=y_dat, kernel=kernel, kpar=pars, ncomps=ncomps)
except RException, rex:
except RException as rex:
raise
log.exception( rex )
stop_err("Encountered error while performing kCCA on the input data: %s" %(rex))
Expand Down
2 changes: 1 addition & 1 deletion tools/kernel_canonical_correlation_analysis/kcca.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<tool id="kcca1" name="Kernel Canonical Correlation Analysis" version="1.0.0">
<tool id="kcca1" name="Kernel Canonical Correlation Analysis" version="1.0.1">
<description> </description>
<requirements>
<requirement type="package" version="1.0.3">rpy</requirement>
Expand Down
4 changes: 2 additions & 2 deletions tools/kernel_principal_component_analysis/kpca.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def stop_err(msg):

try:
kpc = r.kpca(x=r.na_exclude(dat), kernel=kernel, kpar=pars, features=ncomps)
except RException, rex:
except RException as rex:
stop_err("Encountered error while performing kPCA on the input data: %s" %(rex))
set_default_mode(BASIC_CONVERSION)

Expand Down Expand Up @@ -131,4 +131,4 @@ def stop_err(msg):
r.pairs(rotated,labels=r.list(range(1,ncomps+1)),main="Scatterplot of rotated values")
else:
r.plot(rotated, ylab='Comp.1', main="Scatterplot of rotated values")
r.dev_off()
r.dev_off()
6 changes: 3 additions & 3 deletions tools/kernel_principal_component_analysis/kpca.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<tool id="kpca1" name="Kernel Principal Component Analysis" version="1.0.0">
<tool id="kpca1" name="Kernel Principal Component Analysis" version="1.0.1">
<description> </description>
<requirements>
<requirement type="package" version="1.0.3">rpy</requirement>
davebx marked this conversation as resolved.
Show resolved Hide resolved
<requirement type="package" version="2.11.0">R</requirement>
<requirement type="package" version="0.1-4">kernlab</requirement>
<requirement type="package" version="2.11.0">r-base</requirement>
<requirement type="package" version="0.1-4">r-kernlab</requirement>
<requirement type="package" version="1.7.1">numpy</requirement>
<requirement type="package" version="0.7.1">bx-python</requirement>
</requirements>
Expand Down
18 changes: 0 additions & 18 deletions tools/kernel_principal_component_analysis/tool_dependencies.xml

This file was deleted.

2 changes: 1 addition & 1 deletion tools/linear_regression/linear_regression.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def stop_err(msg):
set_default_mode(NO_CONVERSION)
try:
linear_model = r.lm(r("y ~ x"), data = r.na_exclude(dat))
except RException, rex:
except RException as rex:
stop_err("Error performing linear regression on the input data.\nEither the response column or one of the predictor columns contain only non-numeric or invalid values.")
set_default_mode(BASIC_CONVERSION)

Expand Down
Loading