Loading nested/cli/nester.py +3 −0 Original line number Diff line number Diff line Loading @@ -3,6 +3,7 @@ import os import click import glob import shutil from concurrent import futures from datetime import datetime from subprocess import CalledProcessError Loading Loading @@ -66,6 +67,8 @@ def main(input_fasta: str, sketch: bool, format: str, output_fasta_offset: int, process_sequence(sequence, sketcher, sketch, format, output_fasta_offset, output_folder, initial_threshold, threshold_multiplier, number_of_errors, dependency_resolver) shutil.rmtree("/tmp/nested/") end_time = datetime.now() print('Total time: {}'.format(end_time - start_time)) print('Number of errors: {}'.format(number_of_errors[0])) Loading nested/core/tool_interface.py +1 −1 Original line number Diff line number Diff line Loading @@ -11,7 +11,7 @@ from nested.output.output_objects.base_output_object import BaseOutputObject class ToolInterface: def __init__(self, sequence: SeqRecord): self.output_object: Type[BaseOutputObject] self.output_object: BaseOutputObject = None self.sequence: Seq = sequence.seq self.seqId: str = sequence.id Loading nested/core/tools/mite_finder.py +21 −3 Original line number Diff line number Diff line Loading @@ -11,6 +11,7 @@ from nested.core.tool_interface import ToolInterface from nested.entities.mite import Mite from nested.output.output_objects.mite_output_object import MiteOutputObject from nested.config.config import config, args_dict_to_list from nested.utils import intervals class MiteFinder(ToolInterface): Loading @@ -37,8 +38,10 @@ class MiteFinder(ToolInterface): stdout, stderr = process.communicate() mites = self._get_mites() candidates = self._get_mites() mites = self._filter_candidates(candidates) mites.sort(key=lambda e: e.location[0], reverse=True) self.output_object = MiteOutputObject(self.seqId, sequence, mites) return mites Loading @@ -55,6 +58,21 @@ class MiteFinder(ToolInterface): element = Mite(location, score, tir_left, tir_right) result.append(element) result.sort(key=lambda e: e.location[0], reverse=True) return result def _filter_candidates(self, candidates: List[Mite]) -> List[Mite]: mites = [] candidates.sort(key=lambda e: e.score, reverse=True) for candidate in candidates: add = True for mite in mites: if candidate.location == mite.location: continue if intervals.intersect(mite.location, candidate.location): add = False break if add: mites.append(candidate) return mites Loading
nested/cli/nester.py +3 −0 Original line number Diff line number Diff line Loading @@ -3,6 +3,7 @@ import os import click import glob import shutil from concurrent import futures from datetime import datetime from subprocess import CalledProcessError Loading Loading @@ -66,6 +67,8 @@ def main(input_fasta: str, sketch: bool, format: str, output_fasta_offset: int, process_sequence(sequence, sketcher, sketch, format, output_fasta_offset, output_folder, initial_threshold, threshold_multiplier, number_of_errors, dependency_resolver) shutil.rmtree("/tmp/nested/") end_time = datetime.now() print('Total time: {}'.format(end_time - start_time)) print('Number of errors: {}'.format(number_of_errors[0])) Loading
nested/core/tool_interface.py +1 −1 Original line number Diff line number Diff line Loading @@ -11,7 +11,7 @@ from nested.output.output_objects.base_output_object import BaseOutputObject class ToolInterface: def __init__(self, sequence: SeqRecord): self.output_object: Type[BaseOutputObject] self.output_object: BaseOutputObject = None self.sequence: Seq = sequence.seq self.seqId: str = sequence.id Loading
nested/core/tools/mite_finder.py +21 −3 Original line number Diff line number Diff line Loading @@ -11,6 +11,7 @@ from nested.core.tool_interface import ToolInterface from nested.entities.mite import Mite from nested.output.output_objects.mite_output_object import MiteOutputObject from nested.config.config import config, args_dict_to_list from nested.utils import intervals class MiteFinder(ToolInterface): Loading @@ -37,8 +38,10 @@ class MiteFinder(ToolInterface): stdout, stderr = process.communicate() mites = self._get_mites() candidates = self._get_mites() mites = self._filter_candidates(candidates) mites.sort(key=lambda e: e.location[0], reverse=True) self.output_object = MiteOutputObject(self.seqId, sequence, mites) return mites Loading @@ -55,6 +58,21 @@ class MiteFinder(ToolInterface): element = Mite(location, score, tir_left, tir_right) result.append(element) result.sort(key=lambda e: e.location[0], reverse=True) return result def _filter_candidates(self, candidates: List[Mite]) -> List[Mite]: mites = [] candidates.sort(key=lambda e: e.score, reverse=True) for candidate in candidates: add = True for mite in mites: if candidate.location == mite.location: continue if intervals.intersect(mite.location, candidate.location): add = False break if add: mites.append(candidate) return mites