diff ete_lineage_generator.py @ 9:b29ee6a16524 draft

"planemo upload for repository https://github.com/TGAC/earlham-galaxytools/tree/master/tools/ete commit 17c65045b726d0695814bfe761e534f6521786f1"
author earlhaminst
date Tue, 20 Oct 2020 15:10:40 +0000
parents f1eca1158f21
children 2db72467da51
line wrap: on
line diff
--- a/ete_lineage_generator.py	Thu Oct 31 07:48:59 2019 -0400
+++ b/ete_lineage_generator.py	Tue Oct 20 15:10:40 2020 +0000
@@ -41,17 +41,19 @@
     RANK_IDX: mapping from rank names to indices (distance to root/leaf?)
     lower: use lower taxa for filling "NA"s
     """
-    lineage = ncbi.get_lineage(taxid)
-    lineage_ranks = ncbi.get_rank(lineage)
-    lineage_names = ncbi.get_taxid_translator(lineage, try_synonyms=True)
+    lineage_taxids = ncbi.get_lineage(taxid)
+    lineage_ranks = ncbi.get_rank(lineage_taxids)
+    lineage_names = ncbi.get_taxid_translator(lineage_taxids, try_synonyms=True)
     if lower:
-        lineage.reverse()
-    for l in lineage:
-        if not lineage_ranks[l] in RANK_IDX:
+        lineage_taxids.reverse()
+    for parent_taxid in lineage_taxids:
+        parent_rank = lineage_ranks[parent_taxid]
+        if parent_rank not in RANK_IDX:
             continue
-        if ranks[RANK_IDX[lineage_ranks[l]]] != "NA":
+        parent_rank_index = RANK_IDX[parent_rank]
+        if ranks[parent_rank_index] != "NA":
             continue
-        ranks[RANK_IDX[lineage_ranks[l]]] = lineage_names[l]
+        ranks[parent_rank_index] = lineage_names[parent_taxid]
 
 
 # get command line options