Mercurial > repos > yufei-luo > s_mart
comparison SMART/DiffExpAnal/loadHTSeqResultFiles.py @ 18:94ab73e8a190
Uploaded
| author | m-zytnicki |
|---|---|
| date | Mon, 29 Apr 2013 03:20:15 -0400 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| 17:b0e8584489e6 | 18:94ab73e8a190 |
|---|---|
| 1 #!/usr/bin/env python | |
| 2 | |
| 3 import optparse, sys | |
| 4 | |
| 5 | |
| 6 def __main__(): | |
| 7 #Parse Command Line | |
| 8 parser = optparse.OptionParser() | |
| 9 parser.add_option('-i', '--inputs', dest='inputFiles', default=None, help='several input files. (seperated by @ or @@' ) | |
| 10 parser.add_option( '-o', '--output', dest='outputFile', default=None, help='The output list of HTSeq results files(.tabular) on txt format.' ) | |
| 11 ( options, args ) = parser.parse_args() | |
| 12 | |
| 13 | |
| 14 out = open(options.outputFile, 'w') | |
| 15 out.write("label\tfiles\tgroup\n") | |
| 16 if options.inputFiles == None: | |
| 17 raise Exception, 'input file name is not defined!' | |
| 18 | |
| 19 groupCount = 1 | |
| 20 fileCount = 0 | |
| 21 | |
| 22 inputFiles = sys.argv[6:] | |
| 23 print '\n\nthe length of inputfiles is : %s \n' % len(inputFiles) | |
| 24 i = 0 | |
| 25 while i < (len(inputFiles)-1): | |
| 26 if inputFiles[i] == "@": | |
| 27 i += 1 | |
| 28 fileCount = 1 | |
| 29 groupCount += 1 | |
| 30 out.write("Group%s_%s\t%s\t%s\n" % (groupCount, fileCount, inputFiles[i], groupCount)) | |
| 31 else: | |
| 32 fileCount += 1 | |
| 33 out.write("Group%s_%s\t%s\t%s\n" % (groupCount, fileCount, inputFiles[i], groupCount)) | |
| 34 i += 1 | |
| 35 | |
| 36 out.close() | |
| 37 | |
| 38 | |
| 39 | |
| 40 if __name__=="__main__": __main__() |
