Mercurial > repos > devteam > scatterplot
diff scatterplot.py @ 2:53eb2c412783 draft
planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/scatterplot commit de7140295cce07e1bc1697e51dab4271c8d7a8a6
author | devteam |
---|---|
date | Fri, 18 Dec 2015 19:14:12 -0500 |
parents | c30eeaaac86d |
children | 1dacc8aeb452 |
line wrap: on
line diff
--- a/scatterplot.py Tue Oct 13 12:31:01 2015 -0400 +++ b/scatterplot.py Fri Dec 18 19:14:12 2015 -0500 @@ -1,13 +1,17 @@ #!/usr/bin/env python -#Greg Von Kuster +# Greg Von Kuster import sys -from rpy import * + +from numpy import array +from rpy import r + def stop_err(msg): sys.stderr.write(msg) sys.exit() + def main(): in_fname = sys.argv[1] @@ -29,13 +33,13 @@ for i, line in enumerate( file( in_fname ) ): valid = True line = line.rstrip( '\r\n' ) - if line and not line.startswith( '#' ): + if line and not line.startswith( '#' ): row = [] fields = line.split( "\t" ) for column in columns: try: val = fields[column] - if val.lower() == "na": + if val.lower() == "na": row.append( float( "nan" ) ) else: row.append( float( fields[column] ) ) @@ -54,7 +58,7 @@ valid = False skipped_lines += 1 if not first_invalid_line: - first_invalid_line = i+1 + first_invalid_line = i + 1 if valid: matrix.append( row ) @@ -65,7 +69,7 @@ r.plot( array( matrix ), type="p", main=title, xlab=xlab, ylab=ylab, col="blue", pch=19 ) r.dev_off() except Exception, exc: - stop_err( "%s" %str( exc ) ) + stop_err( "%s" % str( exc ) ) else: stop_err( "All values in both columns %s and %s are non-numeric or empty." % ( sys.argv[3], sys.argv[4] ) )