Commit 102d1d7c authored by Pavel Jedlicka's avatar Pavel Jedlicka
Browse files

fixed trf filtering

parent 65e2f929
Loading
Loading
Loading
Loading
+19 −0
Original line number Diff line number Diff line
#!/usr/bin/env python3

from nested.core.nester import Nester
from nested.core.tandem_repeat import TandemRepeat
from nested.core.tools.tandem_repeat_finder import TandemRepeatFinder

class Executor():
    def __init__(self, sequence):
        self.sequence = sequence
        self.tool_order = [TandemRepeatFinder(), Nester()]

    def run_main_loop(self):
        elements = []
        for tool in self.tool_order:
            elements += tool.run(self.sequence)
    
    def _crop_sequence(self, elements):
        for element in elements:
            self.sequence = self.sequence[:element.location[0]] + self.sequence[element.location[1]:]
 No newline at end of file
+6 −3
Original line number Diff line number Diff line
@@ -8,10 +8,11 @@ from nested.core.nested_element import NestedElement
from nested.core.solo_ltrs import SoloLtrs
from nested.logging.logger import NesterLogger
from nested.config.config import config
from nested.core.tool_interface import ToolInterface
import nested.core.tandem_repeat as tandemRepeatFinder


class Nester(object):
class Nester(ToolInterface):
    """Class represent nesting in sequence, recursivelly find best evaluated transposon and crop it until no new transposons found

    Attributes:
@@ -42,7 +43,9 @@ class Nester(object):
        
        nested_list += self._get_unexpanded_transposon_list(cropped_sequence, self.threshold)  # find list of nested transposons
        nested_list = self._expand_transposon_list(nested_list)
        print(len(nested_list))
        nested_list = self._filter_nested_list(nested_list)
        print(len(nested_list))       
        self.nested_element = NestedElement(self.seqid, self.sequence, nested_list)
        
    def _get_unexpanded_transposon_list(self, sequence, threshold):
+1 −1
Original line number Diff line number Diff line
@@ -11,7 +11,7 @@ from nested.utils import intervals

class TandemRepeat(TE):
    def __init__(self, loc, period_size, copies, matches, indels, scor, entropy, monomer):
        super().__init__(location=loc, score=scor)
        super().__init__(location=loc, score=scor, ltr_left_location=[float('nan'), float('nan')])
        self.matches = matches
        self.indels = indels
        self.entropy = entropy
+8 −0
Original line number Diff line number Diff line
#!/usr/bin/env python3

class ToolInterface():
    def run(self, sequence):
        """Runs selected tool, if any arguments are needed they are taken from config.yml or constructor
        Returns: collection of BaseElement
        """        
        pass
 No newline at end of file
+0 −0

Empty file added.

Loading