annotate hub-archive-creator-1.6/twoBitCreator.py @ 0:163b2de763ea draft

Upload the full hubArchiveCreator archive
author rmarenco
date Tue, 01 Mar 2016 19:43:25 -0500
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
163b2de763ea Upload the full hubArchiveCreator archive
rmarenco
parents:
diff changeset
1 #!/usr/bin/python
163b2de763ea Upload the full hubArchiveCreator archive
rmarenco
parents:
diff changeset
2
163b2de763ea Upload the full hubArchiveCreator archive
rmarenco
parents:
diff changeset
3 import os
163b2de763ea Upload the full hubArchiveCreator archive
rmarenco
parents:
diff changeset
4 import tempfile
163b2de763ea Upload the full hubArchiveCreator archive
rmarenco
parents:
diff changeset
5 import subprocess
163b2de763ea Upload the full hubArchiveCreator archive
rmarenco
parents:
diff changeset
6
163b2de763ea Upload the full hubArchiveCreator archive
rmarenco
parents:
diff changeset
7
163b2de763ea Upload the full hubArchiveCreator archive
rmarenco
parents:
diff changeset
8 def twoBitFileCreator(fastaFile, toolDirectory, mySpecieFolder):
163b2de763ea Upload the full hubArchiveCreator archive
rmarenco
parents:
diff changeset
9 """
163b2de763ea Upload the full hubArchiveCreator archive
rmarenco
parents:
diff changeset
10 2bit file creator from a fasta file.
163b2de763ea Upload the full hubArchiveCreator archive
rmarenco
parents:
diff changeset
11 Need faTwoBit kentUtil.
163b2de763ea Upload the full hubArchiveCreator archive
rmarenco
parents:
diff changeset
12 Output a .2bit file
163b2de763ea Upload the full hubArchiveCreator archive
rmarenco
parents:
diff changeset
13 """
163b2de763ea Upload the full hubArchiveCreator archive
rmarenco
parents:
diff changeset
14 baseNameFasta = os.path.basename(fastaFile.name)
163b2de763ea Upload the full hubArchiveCreator archive
rmarenco
parents:
diff changeset
15 suffixTwoBit, extensionTwoBit = os.path.splitext(baseNameFasta)
163b2de763ea Upload the full hubArchiveCreator archive
rmarenco
parents:
diff changeset
16 nameTwoBit = suffixTwoBit + '.2bit'
163b2de763ea Upload the full hubArchiveCreator archive
rmarenco
parents:
diff changeset
17
163b2de763ea Upload the full hubArchiveCreator archive
rmarenco
parents:
diff changeset
18 with open(os.path.join(mySpecieFolder, nameTwoBit), 'w') as twoBitFile:
163b2de763ea Upload the full hubArchiveCreator archive
rmarenco
parents:
diff changeset
19 p = subprocess.Popen(
163b2de763ea Upload the full hubArchiveCreator archive
rmarenco
parents:
diff changeset
20 [os.path.join(toolDirectory, 'tools/faToTwoBit'),
163b2de763ea Upload the full hubArchiveCreator archive
rmarenco
parents:
diff changeset
21 fastaFile.name,
163b2de763ea Upload the full hubArchiveCreator archive
rmarenco
parents:
diff changeset
22 twoBitFile.name])
163b2de763ea Upload the full hubArchiveCreator archive
rmarenco
parents:
diff changeset
23
163b2de763ea Upload the full hubArchiveCreator archive
rmarenco
parents:
diff changeset
24 p.wait()
163b2de763ea Upload the full hubArchiveCreator archive
rmarenco
parents:
diff changeset
25
163b2de763ea Upload the full hubArchiveCreator archive
rmarenco
parents:
diff changeset
26 return twoBitFile