From d773669ff1a414a6fdb4043768af6c7a6d56c168 Mon Sep 17 00:00:00 2001 From: Rutger Vos Date: Fri, 16 Aug 2024 20:40:25 +0200 Subject: [PATCH] reimplement finding tips by processid --- barcode_validator/__main__.py | 9 ++++++++- barcode_validator/taxonomy.py | 5 ----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/barcode_validator/__main__.py b/barcode_validator/__main__.py index 2d0961b..11dd62f 100644 --- a/barcode_validator/__main__.py +++ b/barcode_validator/__main__.py @@ -7,6 +7,13 @@ from barcode_validator.result import DNAAnalysisResult +def get_tip_by_processid(process_id, tree): + for tip in tree.get_terminals(): + if tip.guids['processid'] == process_id: + return tip + return None + + def main(fasta_file_path, bold_sheet, actions): logging.info(f"Starting analysis for file: {fasta_file_path}") @@ -25,7 +32,7 @@ def main(fasta_file_path, bold_sheet, actions): logging.info(f'Processing FASTA record {process_id}') # Lookup species from process_id - tip = list(bold_tree.find_clades({'guid': {'processid': process_id}}))[0] + tip = get_tip_by_processid(process_id, bold_tree) species = tip.name for node in bold_tree.root.get_path(tip): if node.rank == config.get('level'): diff --git a/barcode_validator/taxonomy.py b/barcode_validator/taxonomy.py index a5c1834..48914dd 100644 --- a/barcode_validator/taxonomy.py +++ b/barcode_validator/taxonomy.py @@ -15,11 +15,6 @@ from nbt.Phylo.NCBITaxdmp import Parser as NCBIParser -#def read_bold_taxonomy(spreadsheet): -# logging.info("Reading BOLD taxonomy") -# return BOLDParser(open(spreadsheet)).parse() - - def read_bold_taxonomy(spreadsheet): # Read the Excel file into a BytesIO object with open(spreadsheet, 'rb') as file: