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