Skip to content
Snippets Groups Projects
Commit 24e3efa4 authored by rlapar's avatar rlapar
Browse files

external config

parent 97fea768
No related branches found
No related tags found
1 merge request!12External config
ltr:
path: '/home/radovan/lexa/LTR_finder/ltr_finder'
prosite_path: &prosite_path /home/radovan/lexa/prosite
tRNAdb_path: &tRNAdb_path /home/radovan/lexa/LTR_finder/tRNAdb/Athal-tRNAs.fa
args:
l: 32
S: 3
o: 2
p: 15
g: 80
G: 5
T: 2
w: 2 #don't change, parsing format required!
a: *prosite_path
s: *tRNAdb_path
gt:
path: 'gt'
command: 'sketch'
style_path: &style_path /etc/nested/gt.style
args:
width: 1400
style: *style_path
blastx:
db_path: &db_path /home/radovan/lexa/blastDB/data/gydb_proteins.fa
args:
db: *db_path
outfmt: 5 #don't change, parsing format required!
num_threads: 3
dbsize: 90000
word_size: 2
evalue: 1
logdir: /tmp/nested/logs
...@@ -34,9 +34,9 @@ def main(input_fasta, sketch_only, data_folder): ...@@ -34,9 +34,9 @@ def main(input_fasta, sketch_only, data_folder):
print('Processing {a}: DONE [{b}]'.format(a=sequence.id[:strlen], b=seq_end_time - seq_start_time)) print('Processing {a}: DONE [{b}]'.format(a=sequence.id[:strlen], b=seq_end_time - seq_start_time))
except KeyboardInterrupt: except KeyboardInterrupt:
raise raise
except CalledProcessError: #except CalledProcessError:
number_of_errors += 1 # number_of_errors += 1
print('Processing {}: SUBPROCESS ERROR'.format(sequence.id[:strlen])) # print('Processing {}: SUBPROCESS ERROR'.format(sequence.id[:strlen]))
#except: #except:
# number_of_errors += 1 # number_of_errors += 1
# print('Processing {}: UNEXPECTED ERROR:'.format(sequence.id[:strlen]), sys.exc_info()[0]) # print('Processing {}: UNEXPECTED ERROR:'.format(sequence.id[:strlen]), sys.exc_info()[0])
......
ltr_finder_path = '/home/radovan/lexa/LTR_finder/ltr_finder' import yaml
ltr_finder_prosite_path = '/home/radovan/lexa/prosite'
ltr_finder_tRNAdb_path = '/home/radovan/lexa/LTR_finder/tRNAdb/Athal-tRNAs.fa'
ltr_finder_args = ['-l', '32'] with open('/etc/nested/config.yml') as stream:
ltr_finder_args += ['-S', '3'] config = yaml.load(stream)
ltr_finder_args += ['-o', '2']
ltr_finder_args += ['-p', '15']
ltr_finder_args += ['-g', '80']
ltr_finder_args += ['-G', '5']
ltr_finder_args += ['-T', '2']
ltr_finder_args += ['-w', '2'] #don't change, parsing format required!
ltr_finder_args += ['-a', ltr_finder_prosite_path]
ltr_finder_args += ['-s', ltr_finder_tRNAdb_path]
gt_sketch_path = 'gt' def args_dict_to_list(args):
gt_sketch_args = ['sketch'] args_list = []
gt_sketch_args += ['-width', '1400'] for arg in args:
gt_sketch_args += ['-style', '/home/radovan/git/nested/nested/config/gt.style'] args_list += ['-{}'.format(arg), str(args[arg])]
return args_list
blastx_args = { \ No newline at end of file
'db': '/home/radovan/lexa/blastDB/data/gydb_proteins.fa',
'outfmt': 5, #don't change, parsing format required!
'num_threads': 3,
'dbsize': 90000,
'word_size': 2,
'evalue': 1
}
logdir = '/tmp/nested/logs'
#ADD BLAST PARAMETERS
...@@ -5,7 +5,7 @@ from io import StringIO ...@@ -5,7 +5,7 @@ from io import StringIO
from Bio.Blast import NCBIXML from Bio.Blast import NCBIXML
from Bio.Blast.Applications import NcbiblastxCommandline from Bio.Blast.Applications import NcbiblastxCommandline
from nested.config import config from nested.config.config import config
class Domain(object): class Domain(object):
"""Class representing domain parsed from blastx output. """Class representing domain parsed from blastx output.
...@@ -46,7 +46,7 @@ def run_blastx(sequence): ...@@ -46,7 +46,7 @@ def run_blastx(sequence):
list[Domain]: list of matched domains list[Domain]: list of matched domains
""" """
domains = [] domains = []
blastx_cline = NcbiblastxCommandline(**config.blastx_args) blastx_cline = NcbiblastxCommandline(**config['blastx']['args'])
xml_out, stderr = blastx_cline(stdin=str(sequence)) xml_out, stderr = blastx_cline(stdin=str(sequence))
blast_records = NCBIXML.parse(StringIO(xml_out)) blast_records = NCBIXML.parse(StringIO(xml_out))
try: try:
......
...@@ -4,7 +4,7 @@ from nested.utils import intervals ...@@ -4,7 +4,7 @@ from nested.utils import intervals
from nested.core.gene import Gene from nested.core.gene import Gene
from nested.core.nested_element import NestedElement from nested.core.nested_element import NestedElement
from nested.logging.logger import NesterLogger from nested.logging.logger import NesterLogger
from nested.config import config from nested.config.config import config
class Nester(object): class Nester(object):
"""Class represent nesting in sequence, recursivelly find best evaluated transposon and crop it until no new transposons found """Class represent nesting in sequence, recursivelly find best evaluated transposon and crop it until no new transposons found
...@@ -19,7 +19,7 @@ class Nester(object): ...@@ -19,7 +19,7 @@ class Nester(object):
self.sequence = sequence.seq self.sequence = sequence.seq
self.nested_element = None self.nested_element = None
self._iteration = 0 self._iteration = 0
self._logger = NesterLogger('{}/{}'.format(config.logdir, self.seqid)) self._logger = NesterLogger('{}/{}'.format(config['logdir'], self.seqid))
self._find_nesting() self._find_nesting()
def _find_nesting(self): def _find_nesting(self):
......
...@@ -7,7 +7,7 @@ import re ...@@ -7,7 +7,7 @@ import re
from Bio import SeqIO from Bio import SeqIO
from Bio.SeqRecord import SeqRecord from Bio.SeqRecord import SeqRecord
from nested.config import config from nested.config.config import config, args_dict_to_list
class TE(object): class TE(object):
"""Class representing TE. Every location is in format [from, to]. """Class representing TE. Every location is in format [from, to].
...@@ -65,7 +65,7 @@ def run_ltr_finder(seqid, sequence): ...@@ -65,7 +65,7 @@ def run_ltr_finder(seqid, sequence):
'fasta') 'fasta')
#call LTR finder and feed stdin to it #call LTR finder and feed stdin to it
process = subprocess.Popen([config.ltr_finder_path] + config.ltr_finder_args + ['/tmp/nested/ltr/{}.fa'.format(seqid)], process = subprocess.Popen([config['ltr']['path']] + args_dict_to_list(config['ltr']['args']) + ['/tmp/nested/ltr/{}.fa'.format(seqid)],
stdout=subprocess.PIPE, stdout=subprocess.PIPE,
stderr=subprocess.PIPE) stderr=subprocess.PIPE)
......
...@@ -9,7 +9,7 @@ from Bio.Seq import Seq ...@@ -9,7 +9,7 @@ from Bio.Seq import Seq
from Bio.SeqRecord import SeqRecord from Bio.SeqRecord import SeqRecord
from Bio.SeqFeature import SeqFeature, FeatureLocation from Bio.SeqFeature import SeqFeature, FeatureLocation
from nested.config import config from nested.config.config import config, args_dict_to_list
from nested.utils import intervals from nested.utils import intervals
DEFAULT_DIRPATH = 'data' DEFAULT_DIRPATH = 'data'
...@@ -30,7 +30,7 @@ class Sketcher(object): ...@@ -30,7 +30,7 @@ class Sketcher(object):
self._create_dirs(nested_element.id, dirpath) self._create_dirs(nested_element.id, dirpath)
#find closes parent #find closest parent
nl = nested_element.nested_list nl = nested_element.nested_list
parents = [-1] * len(nl) parents = [-1] * len(nl)
for i in range(len(parents) - 1): for i in range(len(parents) - 1):
...@@ -116,8 +116,8 @@ class Sketcher(object): ...@@ -116,8 +116,8 @@ class Sketcher(object):
#self._create_dirs(id, dirpath) #self._create_dirs(id, dirpath)
null = open(os.devnull, 'w') null = open(os.devnull, 'w')
process = subprocess.check_output( process = subprocess.check_output(
[config.gt_sketch_path] + [config['gt']['path'], config['gt']['command']] +
config.gt_sketch_args + args_dict_to_list(config['gt']['args']) +
['{}/{}/{}.png'.format(dirpath, id, id)] + ['{}/{}/{}.png'.format(dirpath, id, id)] +
['{}/{}/{}.gff'.format(dirpath, id, id)], stderr=null) ['{}/{}/{}.gff'.format(dirpath, id, id)], stderr=null)
setup.sh 0 → 100755
#!/bin/sh
#TODO ADD CONFIG PATH
python3 setup.py install
#remove unnecessary dirs
rm -rf build dist nested.egg-info
#move config file
mkdir -p /etc/nested
cp config.yml /etc/nested/.
cp nested/config/gt.style /etc/nested/.
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment