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