Mercurial > repos > yating-l > jbrowse_hub
comparison utils.py @ 5:e7c80e9b70ae draft
planemo upload for repository https://github.com/Yating-L/jbrowse_hub commit f18ea51d27ec7addfa6413716391cfefebc8acbc-dirty
author | yating-l |
---|---|
date | Tue, 14 Mar 2017 12:24:37 -0400 |
parents | e4f3f2ed4fa5 |
children | a4a54b925c73 |
comparison
equal
deleted
inserted
replaced
4:c7c1474a6b7d | 5:e7c80e9b70ae |
---|---|
24 attr.append(s) | 24 attr.append(s) |
25 gff3.write(';'.join(attr)) | 25 gff3.write(';'.join(attr)) |
26 gff3.write('\n') | 26 gff3.write('\n') |
27 | 27 |
28 def getChromSizes(reference, tool_dir): | 28 def getChromSizes(reference, tool_dir): |
29 #TODO: find a better way instead of shipping the two exec files with the tool | |
29 faToTwoBit = os.path.join(tool_dir, 'faToTwoBit') | 30 faToTwoBit = os.path.join(tool_dir, 'faToTwoBit') |
30 twoBitInfo = os.path.join(tool_dir, 'twoBitInfo') | 31 twoBitInfo = os.path.join(tool_dir, 'twoBitInfo') |
31 try: | 32 try: |
32 twoBitFile = tempfile.NamedTemporaryFile(bufsize=0) | 33 twoBitFile = tempfile.NamedTemporaryFile(bufsize=0) |
33 chrom_sizes = tempfile.NamedTemporaryFile(bufsize=0, suffix='.chrom.sizes', delete=False) | 34 chrom_sizes = tempfile.NamedTemporaryFile(bufsize=0, suffix='.chrom.sizes', delete=False) |
34 except IOError as err: | 35 except IOError as err: |
35 print "Cannot create tempfile err({0}): {1}".format(err.errno, err.strerror) | 36 print "Cannot create tempfile err({0}): {1}".format(err.errno, err.strerror) |
36 try: | 37 try: |
37 p = subprocess.Popen([faToTwoBit, reference, twoBitFile.name]) | 38 p = subprocess.Popen(['faToTwoBit', reference, twoBitFile.name]) |
38 p.communicate() | 39 p.communicate() |
39 except OSError as err: | 40 except OSError as err: |
40 print "Cannot generate twoBitFile from faToTwoBit err({0}): {1}".format(err.errno, err.strerror) | 41 print "Cannot generate twoBitFile from faToTwoBit err({0}): {1}".format(err.errno, err.strerror) |
41 try: | 42 try: |
42 p = subprocess.Popen([twoBitInfo, twoBitFile.name, chrom_sizes.name]) | 43 p = subprocess.Popen(['twoBitInfo', twoBitFile.name, chrom_sizes.name]) |
43 p.communicate() | 44 p.communicate() |
44 except OSError as err: | 45 except OSError as err: |
45 print "Cannot generate chrom_sizes from twoBitInfo err({0}): {1}".format(err.errno, err.strerror) | 46 print "Cannot generate chrom_sizes from twoBitInfo err({0}): {1}".format(err.errno, err.strerror) |
46 return chrom_sizes | 47 return chrom_sizes |
47 | 48 |
140 attribute['Parent'] = parents[gene_id] | 141 attribute['Parent'] = parents[gene_id] |
141 attribute['transcript_id'] = attr_li[1].split()[1].strip('"') | 142 attribute['transcript_id'] = attr_li[1].split()[1].strip('"') |
142 attribute['coverage'] = attr_li[3].split()[1].strip('"') | 143 attribute['coverage'] = attr_li[3].split()[1].strip('"') |
143 write_features(field, attribute, gff3) | 144 write_features(field, attribute, gff3) |
144 gff3.close() | 145 gff3.close() |
146 | |
147 def sanitize_name_path(input_path): | |
148 ''' | |
149 Galaxy will name all the files and dirs as *.dat, | |
150 the function is simply replacing '.' to '_' for the dirs | |
151 ''' | |
152 return input_path.replace('.', '_') |