Skip to content

Commit

Permalink
nonltr.py complete
Browse files Browse the repository at this point in the history
  • Loading branch information
lee212 committed Feb 17, 2016
1 parent 8193304 commit 7910370
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 10 deletions.
32 changes: 23 additions & 9 deletions mgescan/nonltr/nonltr.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
import sys
import os.path
from mgescan import utils
from docopt import docopt
from subprocess import check_call
from multiprocessing import Process
from mgescan.biopython import reverse_complement_fasta, getid
import shutil

class NonLTR(object):
"""MGEScan Non-LTR
class nonLTR(object):
"""MGEScan non-LTR
Usage:
nonltr.py <input> <output> [--mpi=<num>]
Expand All @@ -18,7 +22,7 @@ class NonLTR(object):
"""

name = "nonltr"
ver = 'MGEScan NonLTR 3.0.0'
ver = 'MGEScan nonLTR 3.0.0'
mpi_cmd = "mpi_mgescan"
hmmerv = "3"

Expand Down Expand Up @@ -96,6 +100,9 @@ def post_process2(self):
self.run_cmd(cmd)

def backward(self):

reverse_path = self.genome_path + "_b"
self.reverse_complement(reverse_path)
if self.nmpi:
cmd = self._padding("mpirun", self.p_np, self.p_mpi_option,
self.p_mgescan_mpi_cmd, self.p_prg, self.p_genome_b,
Expand All @@ -104,13 +111,13 @@ def backward(self):
else:
from os import listdir
from os.path import isfile, join
mypath = self.genome_path + "_b"
for f in listdir(mypath):
fpath = join(mypath, f)
for f in listdir(reverse_path):
fpath = join(reverse_path, f)
if isfile(fpath):
p = Process(target=self.run_hmm, args=("backward",fpath,))
p.start()
self.post_process("backward")
shutil.rmtree(reverse_path)

def _padding(self, *args):
res = ""
Expand All @@ -121,9 +128,16 @@ def _padding(self, *args):
else:
return res

def reverse_complement(self, directory):
mypath = self.genome_path
for (dirpath, dirnames, filenames) in os.walk(mypath):
break
utils.create_directory(directory, False)
for name in filenames:
file_path = utils.get_abspath(dirpath + "/" + name)
reverse_complement_fasta(file_path, directory)

def run_cmd(self, cmd):
print cmd
return
try:
retcode = check_call(cmd.split())
if retcode < 0:
Expand Down Expand Up @@ -154,5 +168,5 @@ def run(self):
self.post_process2()

if __name__ == '__main__':
obj = NonLTR()
obj = nonLTR()
obj.run()
4 changes: 3 additions & 1 deletion mgescan/nonltr/run_MGEScan.pl
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@
my $nmpi;
my $host = hostname;

my $debug, $host_file, $hf_option;
my $debug;
my $host_file;
my $hf_option;
$debug = $ENV{'MGESCAN_DEBUG'};
$host_file = "";
$hf_option = "";
Expand Down

0 comments on commit 7910370

Please sign in to comment.