annotate fastqc/fastqc.py @ 0:1d373f219445 default tip

Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
author jjohnson
date Tue, 07 Jun 2011 17:22:05 -0400
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
1d373f219445 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
1 #!/usr/bin/env python
1d373f219445 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
2
1d373f219445 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
3 """
1d373f219445 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
4 Runs FastQC on a fastq file;
1d373f219445 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
5 TODO: more documentation
1d373f219445 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
6
1d373f219445 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
7 usage: fastqc.py [options]
1d373f219445 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
8 -i, --input=i: The fastq input file
1d373f219445 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
9 -n, --name=n: The fastq input name
1d373f219445 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
10 -c, --contaminants=c: A contaminants file
1d373f219445 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
11 -r, --report=r: The html summary report file
1d373f219445 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
12 -D, --dir=D: The dir for report files
1d373f219445 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
13 -d, --data=d: The data output text file
1d373f219445 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
14 """
1d373f219445 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
15
1d373f219445 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
16 import optparse, os, shutil, subprocess, sys, tempfile, re, string
1d373f219445 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
17
1d373f219445 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
18 def stop_err( msg ):
1d373f219445 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
19 sys.stderr.write( '%s\n' % msg )
1d373f219445 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
20 sys.exit()
1d373f219445 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
21
1d373f219445 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
22 def __main__():
1d373f219445 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
23 #Parse Command Line
1d373f219445 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
24 parser = optparse.OptionParser()
1d373f219445 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
25 parser.add_option( '-i', '--input', dest='input', help='The sequence input file' )
1d373f219445 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
26 parser.add_option( '-f', '--format', dest='format', help='The sequence input file format' )
1d373f219445 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
27 parser.add_option( '-n', '--name', dest='name', help='The fastq input name' )
1d373f219445 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
28 parser.add_option( '-c', '--contaminants', dest='contaminants', help='A contaminants file' )
1d373f219445 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
29 parser.add_option( '-r', '--report', dest='report', help='The HTML report' )
1d373f219445 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
30 parser.add_option( '-D', '--dir', dest='outdir', help='The dir for report files' )
1d373f219445 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
31 parser.add_option( '-d', '--data', dest='data', help='The output data text file' )
1d373f219445 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
32 (options, args) = parser.parse_args()
1d373f219445 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
33 if options.input == None:
1d373f219445 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
34 stop_err("Misssing option --input")
1d373f219445 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
35 params = []
1d373f219445 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
36 #params.append('-Xmx250m')
1d373f219445 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
37 params.append('-Djava.awt.headless=true')
1d373f219445 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
38 name = 'input'
1d373f219445 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
39 format = 'fastq'
1d373f219445 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
40 if options.outdir != None:
1d373f219445 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
41 os.makedirs(options.outdir)
1d373f219445 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
42 if options.contaminants != None and options.contaminants != 'None':
1d373f219445 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
43 params.append("-c %s" % options.contaminants)
1d373f219445 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
44 if options.name != None and options.name != 'None':
1d373f219445 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
45 name = re.sub('[^a-zA-Z0-9_.-]','_',options.name)
1d373f219445 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
46 if options.format != None and options.format != 'None':
1d373f219445 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
47 format = options.format
1d373f219445 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
48 params.append("-f %s" % options.format)
1d373f219445 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
49 # FastQC relies on the extension to determine file format .sam .bam or .fastq
1d373f219445 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
50 if not name.endswith('.'+format):
1d373f219445 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
51 name = '.'.join((name,format))
1d373f219445 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
52 # make temp directory
1d373f219445 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
53 buffsize = 1048576
1d373f219445 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
54 tmp_dir = tempfile.mkdtemp()
1d373f219445 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
55 params.append("-o %s" % tmp_dir)
1d373f219445 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
56 # print("tmp_dir %s" % tmp_dir)
1d373f219445 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
57 try:
1d373f219445 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
58 # make a link to the input fastq in the tmp_dir
1d373f219445 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
59 # FastQC will generate output in the same dir that it finds its input
1d373f219445 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
60 fastq = os.path.join(tmp_dir,name)
1d373f219445 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
61 os.symlink( options.input, fastq)
1d373f219445 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
62 # generate commandline
1d373f219445 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
63 cmd = 'fastqc %s %s' % (' '.join(params),fastq)
1d373f219445 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
64 # need to nest try-except in try-finally to handle 2.4
1d373f219445 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
65 try:
1d373f219445 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
66 try:
1d373f219445 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
67 tmp_stderr_name = tempfile.NamedTemporaryFile( dir=tmp_dir,suffix='.err' ).name
1d373f219445 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
68 tmp_stderr = open( tmp_stderr_name, 'wb' )
1d373f219445 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
69 tmp_stdout_name = tempfile.NamedTemporaryFile( dir=tmp_dir,suffix='.out' ).name
1d373f219445 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
70 tmp_stdout = open( tmp_stdout_name, 'wb' )
1d373f219445 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
71 proc = subprocess.Popen( args=cmd, shell=True, cwd=tmp_dir, stderr=tmp_stderr.fileno(), stdout=tmp_stdout.fileno() )
1d373f219445 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
72 returncode = proc.wait()
1d373f219445 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
73 tmp_stderr.close()
1d373f219445 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
74 # get stderr, allowing for case where it's very large
1d373f219445 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
75 tmp_stderr = open( tmp_stderr_name, 'rb' )
1d373f219445 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
76 stderr = ''
1d373f219445 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
77 try:
1d373f219445 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
78 while True:
1d373f219445 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
79 stderr += tmp_stderr.read( buffsize )
1d373f219445 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
80 if not stderr or len( stderr ) % buffsize != 0:
1d373f219445 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
81 break
1d373f219445 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
82 except OverflowError:
1d373f219445 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
83 pass
1d373f219445 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
84 tmp_stderr.close()
1d373f219445 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
85 if returncode != 0:
1d373f219445 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
86 raise Exception, stderr
1d373f219445 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
87 except Exception, e:
1d373f219445 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
88 raise Exception, 'Error executing FastQC. ' + str( e )
1d373f219445 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
89 # remove the input file symlink so it does get copied
1d373f219445 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
90 os.remove(fastq)
1d373f219445 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
91 # remove the stdout and stderr files so they do not get copied
1d373f219445 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
92 os.remove(tmp_stderr_name)
1d373f219445 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
93 os.remove(tmp_stdout_name)
1d373f219445 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
94 # array to retrieve results of each test so that it gets displayed in the tool info
1d373f219445 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
95 tests = []
1d373f219445 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
96 # move result to outdir
1d373f219445 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
97 # Need to flatten the dir hierachy in order for galaxy to serve the href links
1d373f219445 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
98 for root, dirs, files in os.walk(tmp_dir):
1d373f219445 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
99 for fname in files:
1d373f219445 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
100 path = os.path.join(root,fname)
1d373f219445 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
101 # print("%s" % fname)
1d373f219445 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
102 if re.match('.+\.zip',fname):
1d373f219445 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
103 pass
1d373f219445 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
104 elif fname == 'fastqc_report.html':
1d373f219445 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
105 if options.outdir != None:
1d373f219445 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
106 fsrc = open(path,'r')
1d373f219445 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
107 # fdst = open(os.path.join(options.outdir,fname),'w')
1d373f219445 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
108 fdst = open(options.report,'w')
1d373f219445 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
109 try:
1d373f219445 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
110 for line in fsrc:
1d373f219445 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
111 if line.find('footer') > 0:
1d373f219445 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
112 # add extra links in case someone prefers raw text
1d373f219445 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
113 fdst.write('<p><a href="summary.txt">FastQC Summary text report</a>')
1d373f219445 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
114 fdst.write('<p><a href="fastqc_data.txt">FastQC Report Data</a>')
1d373f219445 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
115 # copy lines removing subdirs from links
1d373f219445 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
116 fdst.write(re.sub('Icons/|Images/','',line))
1d373f219445 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
117 finally:
1d373f219445 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
118 fsrc.close()
1d373f219445 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
119 fdst.close()
1d373f219445 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
120 else:
1d373f219445 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
121 if options.outdir != None:
1d373f219445 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
122 shutil.copy(path,options.outdir)
1d373f219445 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
123 if fname == 'summary.txt':
1d373f219445 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
124 # Use the contents of this file to put stdout info into the HistoryDataset panel
1d373f219445 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
125 fsrc = open(path,'r')
1d373f219445 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
126 try:
1d373f219445 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
127 for line in fsrc:
1d373f219445 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
128 (grade,test,seq) = string.split(line,' ')
1d373f219445 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
129 tests.append("%s %s" % ('+' if grade == 'PASS' else '-',re.sub('equence','eq',test)))
1d373f219445 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
130 finally:
1d373f219445 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
131 fsrc.close()
1d373f219445 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
132 elif fname == 'fastqc_data.txt':
1d373f219445 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
133 if options.data != None:
1d373f219445 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
134 # copy the fastqc_data.txt file to the dataset data
1d373f219445 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
135 shutil.copy(path,options.data)
1d373f219445 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
136 cnt = '?'
1d373f219445 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
137 flen = '?'
1d373f219445 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
138 gc = '?'
1d373f219445 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
139 fsrc = open(path,'r')
1d373f219445 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
140 try:
1d373f219445 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
141 for line in fsrc:
1d373f219445 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
142 m = re.match('^Total Sequences (\d+)',line)
1d373f219445 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
143 if m:
1d373f219445 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
144 cnt = m.groups()[-1]
1d373f219445 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
145 m = re.match('^Sequence length (\d+)',line)
1d373f219445 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
146 if m:
1d373f219445 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
147 flen = m.groups()[-1]
1d373f219445 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
148 m = re.match('^%GC (\d+)',line)
1d373f219445 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
149 if m:
1d373f219445 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
150 gc = m.groups()[-1]
1d373f219445 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
151 finally:
1d373f219445 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
152 fsrc.close()
1d373f219445 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
153 #print to stdout so that this appears in the tool dataset info
1d373f219445 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
154 print("Seqs %s, Len %s, GC %s" %(cnt,flen,gc))
1d373f219445 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
155 #print to stdout so that this appears in the tool dataset info
1d373f219445 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
156 print("%s" % '\n'.join(tests))
1d373f219445 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
157 except Exception, e:
1d373f219445 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
158 stop_err( 'Fastq failed.\n' + str( e ) )
1d373f219445 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
159 finally:
1d373f219445 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
160 # clean up temp dir, put in a try block so we don't fail on stale nfs handles
1d373f219445 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
161 try:
1d373f219445 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
162 if os.path.exists( tmp_dir ):
1d373f219445 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
163 shutil.rmtree( tmp_dir )
1d373f219445 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
164 except Exception, e:
1d373f219445 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
165 pass
1d373f219445 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
166
1d373f219445 Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
jjohnson
parents:
diff changeset
167 if __name__=="__main__": __main__()