annotate SMART/DiffExpAnal/loadMultiFastqFiles.py @ 31:0ab839023fe4

Uploaded
author m-zytnicki
date Tue, 30 Apr 2013 14:33:21 -0400
parents 94ab73e8a190
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='outputSingleFile', default=None, help='The output list of fastq files on txt format.' )
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
11 parser.add_option( '', '--pairedEnd', dest='outputPaireFile', default=None, help='paired end option help to upload the corresponding paired end complementary fastq files' )
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
12 ( options, args ) = parser.parse_args()
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
13
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
14
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
15
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
16 if options.outputSingleFile == None:
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
17 raise Exception, 'OutSingleFile txt file name is not defined!'
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
18 else:
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
19 outSingle = open(options.outputSingleFile, 'w')
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
20
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
21 if options.inputFiles == None:
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
22 raise Exception, 'input file name is not defined!'
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
23
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
24 groupCount = 1
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
25 fileCount = 0
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
26
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
27 if options.outputPaireFile == None:
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
28 inputFiles = sys.argv[4:]
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
29 i = 0
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
30 while i < (len(inputFiles)-1):
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
31 if inputFiles[i] == "@":
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
32 i += 1
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
33 fileCount = 1
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
34 groupCount += 1
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
35 outSingle.write("Group%s_%s\t%s\n" % (groupCount, fileCount, inputFiles[i]))
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
36
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
37 else:
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
38 fileCount += 1
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
39 outSingle.write("Group%s_%s\t%s\n" % (groupCount, fileCount, inputFiles[i]))
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
40
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
41 i += 1
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
42 else:
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
43 inputFiles = sys.argv[6:]
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
44 print '\n\nthe length of inputfiles is : %s \n' % len(inputFiles)
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
45 outPaire = open(options.outputPaireFile, 'w')
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
46 i = 0
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
47 while i < (len(inputFiles)-1):
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
48 if inputFiles[i] == "@@":
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
49 i += 1
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
50 outPaire.write("Group%s_%s\t%s\n" % (groupCount, fileCount, inputFiles[i]))
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
51 elif inputFiles[i] == "@":
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
52 i += 1
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
53 fileCount = 1
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
54 groupCount += 1
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
55 outSingle.write("Group%s_%s\t%s\n" % (groupCount, fileCount, inputFiles[i]))
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
56 else:
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
57 fileCount += 1
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
58 outSingle.write("Group%s_%s\t%s\n" % (groupCount, fileCount, inputFiles[i]))
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
59
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
60 i += 1
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
61
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
62
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
63
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
64 outPaire.close()
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
65
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
66 outSingle.close()
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
67
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
68
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
69
94ab73e8a190 Uploaded
m-zytnicki
parents:
diff changeset
70 if __name__=="__main__": __main__()