diff 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
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hub-archive-creator-1.6/twoBitCreator.py	Tue Mar 01 19:43:25 2016 -0500
@@ -0,0 +1,26 @@
+#!/usr/bin/python
+
+import os
+import tempfile
+import subprocess
+
+
+def twoBitFileCreator(fastaFile, toolDirectory, mySpecieFolder):
+    """
+    2bit file creator from a fasta file.
+    Need faTwoBit kentUtil.
+    Output a .2bit file
+    """
+    baseNameFasta = os.path.basename(fastaFile.name)
+    suffixTwoBit, extensionTwoBit = os.path.splitext(baseNameFasta)
+    nameTwoBit = suffixTwoBit + '.2bit'
+
+    with open(os.path.join(mySpecieFolder, nameTwoBit), 'w') as twoBitFile:
+        p = subprocess.Popen(
+            [os.path.join(toolDirectory, 'tools/faToTwoBit'),
+                fastaFile.name,
+                twoBitFile.name])
+
+        p.wait()
+
+    return twoBitFile