0
|
1 #!/usr/bin/python
|
|
2
|
|
3 import os
|
|
4 import tempfile
|
|
5 import subprocess
|
|
6
|
|
7
|
|
8 def twoBitFileCreator(fastaFile, toolDirectory, mySpecieFolder):
|
|
9 """
|
|
10 2bit file creator from a fasta file.
|
|
11 Need faTwoBit kentUtil.
|
|
12 Output a .2bit file
|
|
13 """
|
|
14 baseNameFasta = os.path.basename(fastaFile.name)
|
|
15 suffixTwoBit, extensionTwoBit = os.path.splitext(baseNameFasta)
|
|
16 nameTwoBit = suffixTwoBit + '.2bit'
|
|
17
|
|
18 with open(os.path.join(mySpecieFolder, nameTwoBit), 'w') as twoBitFile:
|
|
19 p = subprocess.Popen(
|
|
20 [os.path.join(toolDirectory, 'tools/faToTwoBit'),
|
|
21 fastaFile.name,
|
|
22 twoBitFile.name])
|
|
23
|
|
24 p.wait()
|
|
25
|
|
26 return twoBitFile
|