annotate SMART/DiffExpAnal/loadHTSeqResultFiles.py @ 18:94ab73e8a190

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