Mercurial > repos > drosofff > msp_oases
comparison oases_optimiser.py @ 0:eedbe32980bb draft
planemo upload for repository https://bitbucket.org/drosofff/gedtools/
author | drosofff |
---|---|
date | Sun, 21 Jun 2015 14:38:06 -0400 |
parents | |
children | b5df930313cc |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:eedbe32980bb |
---|---|
1 #!/usr/bin/env python | |
2 | |
3 """ | |
4 VelvetOptimiser Wrapper | |
5 refactored using the adaptation of | |
6 Konrad Paszkiewicz University of Exeter, UK. | |
7 | |
8 """ | |
9 import pkg_resources; | |
10 import logging, os, string, sys, tempfile, glob, shutil, types, urllib | |
11 import shlex, subprocess | |
12 from optparse import OptionParser, OptionGroup | |
13 from stat import * | |
14 | |
15 | |
16 def stop_err( msg ): | |
17 sys.stderr.write( "%s\n" % msg ) | |
18 sys.exit() | |
19 | |
20 def __main__(): | |
21 job_dir= os.getcwd() | |
22 #tmp_work_dir = tempfile.mkdtemp(dir = job_dir) # make temp directory in the job_dir | |
23 #Parse Command Line | |
24 starthash = sys.argv[1] | |
25 endhash = sys.argv[2] | |
26 inputs = sys.argv[3] | |
27 transcripts = sys.argv[4] | |
28 transcripts_path = '' | |
29 cmdline = "oases_optimiser.sh %s %s '%s' %s 2&1>/dev/null" % (starthash, endhash, inputs, job_dir) # 2&1>/dev/null | |
30 print >> sys.stdout, cmdline # so will appear as blurb for file | |
31 print >> sys.stdout, job_dir | |
32 print >> sys.stdout, "PATH = %s" % (os.environ['PATH']) | |
33 try: | |
34 proc = subprocess.Popen( args=cmdline, shell=True, stderr=subprocess.PIPE ) # cwd=job_dir | |
35 returncode = proc.wait() | |
36 # get stderr, allowing for case where it's very large | |
37 stderr = '' | |
38 buffsize = 1048576 | |
39 try: | |
40 while True: | |
41 stderr += proc.stderr.read( buffsize ) | |
42 if not stderr or len( stderr ) % buffsize != 0: | |
43 break | |
44 except OverflowError: | |
45 pass | |
46 if returncode != 0: | |
47 raise Exception, stderr | |
48 except Exception, e: | |
49 stop_err( 'Error running oases_optimiser.py' + str( e ) ) | |
50 out = open(transcripts,'w') | |
51 transcript_path = os.path.join(job_dir, "MergedAssemblyFolder", 'transcripts.fa') | |
52 print >> sys.stdout, transcript_path | |
53 for line in open(transcript_path): | |
54 out.write( "%s" % (line) ) | |
55 out.close() | |
56 | |
57 if __name__ == "__main__": __main__() |