Skip to content

Commit

Permalink
fix module and Spot loading
Browse files Browse the repository at this point in the history
  • Loading branch information
JeanMainguy committed Aug 11, 2023
1 parent 6d1b6fc commit fc5bca2
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions ppanggolin/formats/writeFlat.py
Original file line number Diff line number Diff line change
Expand Up @@ -635,15 +635,15 @@ def write_gff(output: str, compress: bool = False):
for rgp in pan.regions:
contig_to_rgp[rgp.contig].append(rgp)

rgp_to_spot = {rgp:spot for spot in pan.spots for rgp in spot.rgp}
rgp_to_spot_id = {rgp:f"spot_{spot.ID}" for spot in pan.spots for rgp in spot.regions}

for org in pan.organisms:
print(org)
write_gff_file(org, outdir, compress, contig_to_rgp, rgp_to_spot)
write_gff_file(org, outdir, compress, contig_to_rgp, rgp_to_spot_id)
break
logging.getLogger().info("Done writing the gff files")

def write_gff_file(org, outdir, compress, contig_to_rgp, rgp_to_spot):
def write_gff_file(org, outdir, compress, contig_to_rgp, rgp_to_spotid):
"""
Write the gff file of the provided organism.
Expand Down Expand Up @@ -677,7 +677,7 @@ def write_gff_file(org, outdir, compress, contig_to_rgp, rgp_to_spot):

strand = feature.strand

strand = feature.strand
source = "."

attributes = [("ID", feature.ID),
("Name", feature.name),
Expand All @@ -699,11 +699,13 @@ def write_gff_file(org, outdir, compress, contig_to_rgp, rgp_to_spot):

elif type(feature) == Region:
feat_type = "region"
source = "ppanggolin"
strand = "."
score = feature.score # TODO is RGP score make sens and do we want it in gff file?
attributes = [
("Name", feature.name),
("Spot", rgp_to_spot.get(feature.name, "No_spot"))
("Spot", rgp_to_spotid.get(feature, "No_spot")),
("Note", "Region of Genomic Plasticity (RGP)")
]


Expand All @@ -714,7 +716,7 @@ def write_gff_file(org, outdir, compress, contig_to_rgp, rgp_to_spot):
attributes_str = ';'.join([f"{k}={v}" for k,v in attributes if v != "" and v is not None])

line = [contig.name,
".", # Source
source, # Source
feat_type,
feature.start,
feature.stop,
Expand Down Expand Up @@ -1091,13 +1093,13 @@ def write_flat_files(pangenome: Pangenome, output: str, cpu: int = 1, soft_core:
metatype = "families"
else:
needMetadata = False
if regions or spots or borders or spot_modules or gff:
if regions or spots or borders or spot_modules:
needRegions = True
if spots or borders or spot_modules: # or projection:
needSpots = True
if modules or spot_modules: # or projection:
needModules = True
if projection:
if projection or gff:
needRegions = True if pan.status["predictedRGP"] == "inFile" else False
needSpots = True if pan.status["spots"] == "inFile" else False
needModules = True if pan.status["modules"] == "inFile" else False
Expand Down

0 comments on commit fc5bca2

Please sign in to comment.