forked from DerKevinRiehl/transposon_annotation_tools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtransposonPSI
57 lines (45 loc) · 1.49 KB
/
transposonPSI
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/usr/bin/env python
from shutil import copyfile, rmtree
from os import path
import os.path
import sys
# Methods
def getArgument(args, title):
for i in range(0, len(args)):
if(args[i].startswith("-"+title)):
if(i<len(args)-1):
return args[i+1]
else:
return ""
return ""
args = sys.argv
# Parameters
tempFolder = getArgument(args, "tempFolder")
resultFolder = getArgument(args, "resultFolder")
fastaFile = getArgument(args, "fastaFile")
mode = getArgument(args, "mode")
# Localize share folder
script_dir = os.path.dirname(__file__)
parent_dir = os.path.abspath(os.path.join(script_dir, os.pardir))
share_dir = os.path.join(parent_dir, "share", "transposonPSIcli")
print(script_dir)
print(parent_dir)
print(share_dir)
# Create temp folder
if(path.isdir(tempFolder)):
rmtree(tempFolder)
os.mkdir(tempFolder)
# Copy code into temp folder
os.system("cp -r "+share_dir+" "+tempFolder)
# Copy fasta to temp folder
os.system("cp "+fastaFile+" "+os.path.join(tempFolder,"transposonPSIcli"))
# Go to folder and run transposonPSI
fastaFileName = os.path.basename(fastaFile)
os.system("cd "+os.path.join(tempFolder,"transposonPSIcli")+" && ./transposonPSI.pl "+fastaFileName+" "+mode)
# Copy results back
if(not path.isdir(resultFolder)):
os.mkdir(resultFolder)
os.system("cp "+os.path.join(tempFolder,"transposonPSIcli","*.TPSI.allHits*")+" "+resultFolder)
# Delete temp folder
rmtree(tempFolder)
print("finished completely...")