comparison scatterplot.py @ 3:efda9a4a50e7 draft default tip

planemo upload for repository https://github.com/galaxyproject/tools-devteam/tree/master/tools/scatterplot commit 405b0656c97b3971605e09f77cf46ca1f4870346
author devteam
date Sat, 03 Jun 2017 09:29:30 -0400
parents 4f8b9e70fda0
children
comparison
equal deleted inserted replaced
2:4f8b9e70fda0 3:efda9a4a50e7
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Greg Von Kuster 2 # Greg Von Kuster
3
4 from __future__ import print_function
3 5
4 import sys 6 import sys
5 7
6 from numpy import array 8 from numpy import array
7 import rpy2.rpy_classic as rpy 9 import rpy2.rpy_classic as rpy
33 skipped_lines = 0 35 skipped_lines = 0
34 first_invalid_line = 0 36 first_invalid_line = 0
35 invalid_value = '' 37 invalid_value = ''
36 invalid_column = 0 38 invalid_column = 0
37 i = 0 39 i = 0
38 for i, line in enumerate( file( in_fname ) ): 40 for i, line in enumerate( open( in_fname ) ):
39 valid = True 41 valid = True
40 line = line.rstrip( '\r\n' ) 42 line = line.rstrip( '\r\n' )
41 if line and not line.startswith( '#' ): 43 if line and not line.startswith( '#' ):
42 row = [] 44 row = []
43 fields = line.split( "\t" ) 45 fields = line.split( "\t" )
72 try: 74 try:
73 a = numpy2ri(array( matrix )) 75 a = numpy2ri(array( matrix ))
74 r.pdf( out_fname, 8, 8 ) 76 r.pdf( out_fname, 8, 8 )
75 r.plot( a, type="p", main=title, xlab=xlab, ylab=ylab, col="blue", pch=19 ) 77 r.plot( a, type="p", main=title, xlab=xlab, ylab=ylab, col="blue", pch=19 )
76 r.dev_off() 78 r.dev_off()
77 except Exception, exc: 79 except Exception as exc:
78 stop_err( "%s" % str( exc ) ) 80 stop_err( "%s" % str( exc ) )
79 else: 81 else:
80 stop_err( "All values in both columns %s and %s are non-numeric or empty." % ( sys.argv[3], sys.argv[4] ) ) 82 stop_err( "All values in both columns %s and %s are non-numeric or empty." % ( sys.argv[3], sys.argv[4] ) )
81 83
82 print "Scatter plot on columns %s, %s. " % ( sys.argv[3], sys.argv[4] ) 84 print("Scatter plot on columns %s, %s. " % ( sys.argv[3], sys.argv[4] ))
83 if skipped_lines > 0: 85 if skipped_lines > 0:
84 print "Skipped %d lines starting with line #%d, value '%s' in column %d is not numeric." % ( skipped_lines, first_invalid_line, invalid_value, invalid_column ) 86 print("Skipped %d lines starting with line #%d, value '%s' in column %d is not numeric." % ( skipped_lines, first_invalid_line, invalid_value, invalid_column ))
85 87
86 if __name__ == "__main__": 88 if __name__ == "__main__":
87 main() 89 main()