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