#!/usr/bin/env python ################################################ # CONVERTS SI NOTATION NUMBERS TO OPENOFFICE # # CALC COMPATIBLE STANDARD NOTATION NUMBERS # # THIS IS OPEN SOURCE CODE (YAY!) # ################################################ # LICENSE # This code is licensed under the Creative Commons 3.0 # Attribution + ShareAlike license - for details see: # http://creativecommons.org/licenses/by-sa/3.0/ # # DATE: February 27th, 2014 # # PROGRAM AUTHOR (PROGRAMMER) # Graham Alvare - home.cc.umanitoba.ca/~alvare # # CO-AUTHORS/ACKNOWLEDGEMENTS # Justin Zhang - for providing me information on the SAM format, # and test data to build and debug this program. # Dr. Brian Fristensky - my work supervisor, and the man who introduced # me to the wonderful field of bioinformatics. # # QUESTIONS & COMMENTS # If you have any questions, please contact me: alvare@cc.umanitoba.ca # I usually get back to people within 1-2 weekdays (weekends, I am slower) # # P.S. Please also let me know of any bugs, or if you have any suggestions. # I am generally happy to help create new tools, or modify my existing # tools to make them more useful. # # Happy usage! import sys, os, os.path, csv, re, collections if __name__=="__main__": if len(sys.argv) > 1: for filename in sys.argv[1:]: in_file = open(filename, 'rU') #outfile = open("nonsi_" + filename, "w") #csvout = csv.writer(outfile, dialect='excel-tab') csvout = csv.writer(sys.stdout, dialect='excel-tab') # Open the CSV file and parse each row for row in csv.reader(in_file, dialect='excel-tab'): fixed = list() for col in row: matches = re.search(r"\d+(.?)\s*[eE]\s*[+-]?\s*\d+", s) f csvout.writerow(fixed) #outfile.close() else: print "Synopsis: fixes SI notation in CSV files (for OO Calc/Excel)" print "Usage: csv_fixexp.py "