Skip to content

Commit

Permalink
Merge pull request #246 from labgem/fix_proksee_module
Browse files Browse the repository at this point in the history
Fix proksee module
  • Loading branch information
jpjarnoux authored Jul 3, 2024
2 parents e94b151 + 32c1f3c commit 5173797
Showing 1 changed file with 17 additions and 13 deletions.
30 changes: 17 additions & 13 deletions ppanggolin/formats/write_proksee.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def write_legend_items(features: List[str], module_to_color: Dict[Module, str] =

if module_to_color is not None and ("modules" in features or "all" in features):
for mod, color in sorted(module_to_color.items(), key=lambda x: x[0].ID):
legend_data["items"].append({"name": f"module_{mod.ID}",
legend_data["items"].append({"name": str(mod),
"decoration": "arc",
"swatchColor": color,
"visible": False})
Expand Down Expand Up @@ -324,23 +324,27 @@ def write_modules(organism: Organism, gf2genes: Dict[str, List[Gene]], metadata_

if gf_intersection:
# Calculate the completion percentage
completion = round(100 * len(gf_intersection) / len(set(module.families)), 1)

metadata_for_proksee = {'completion': round(100 * len(gf_intersection) / len(set(module.families)), 1)}

metadata_for_proksee.update(module.formatted_metadata_dict(metadata_sep))
# Create module data entries for genes within intersecting gene families
for gf in gf_intersection:
for gene in gf2genes[gf.name]:
modules_data_list.append({
"name": f"Module_{module.ID}",
"presence": "Module",
"start": gene.start,
"stop": gene.stop,
"contig": gene.contig.name,
"legend": f"module_{module.ID}",
"source": "Module",
"tags": [f'{completion}% complete'],
"meta": module.formatted_metadata_dict(metadata_sep)
for start, stop in gene.coordinates:
modules_data_list.append({
"name": str(module),
"presence": "Module",
"start": start,
"stop": stop,
"contig": gene.contig.name,
"legend": str(module),
"source": "Module",
"tags": [],
"meta": metadata_for_proksee
})



return modules_data_list


Expand Down

0 comments on commit 5173797

Please sign in to comment.