Skip to content

Commit

Permalink
Merge pull request #169 from polio-nanopore/paf-parsing
Browse files Browse the repository at this point in the history
yaml parsing and dev info and citation box in report
  • Loading branch information
aineniamh authored Oct 26, 2023
2 parents 92b5363 + 85be6e4 commit 3b8507f
Show file tree
Hide file tree
Showing 6 changed files with 90 additions and 21 deletions.
2 changes: 1 addition & 1 deletion piranha/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def main(sysargs = sys.argv[1:]):
o_group.add_argument('--save-config',action="store_true",help=f"Output the config file with all parameters used")

misc_group = parser.add_argument_group('Misc options')
misc_group.add_argument('--runname',action="store",help=f"Run name to appear in report. Default: {VALUE_RUN_NAME}")
misc_group.add_argument('--runname',action="store",help=f"Run name to appear in report. Default: {VALUE_RUNNAME}")
misc_group.add_argument('--username',action="store",help="Username to appear in report. Default: no user name")
misc_group.add_argument('--institute',action="store",help="Institute name to appear in report. Default: no institute name")
misc_group.add_argument('--orientation',action="store",help="Orientation of barcodes in wells on a 96-well plate. If `well` is supplied as a column in the barcode.csv, this default orientation will be overwritten. Default: `vertical`. Options: `vertical` or `horizontal`.")
Expand Down
27 changes: 23 additions & 4 deletions piranha/data/report.mako
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,15 @@
padding: 10px;
flex: 50%;
}
.info_box {
background-color: #eee;
color: #444;
padding: 13px;
width: 100%;
border: none;
text-align: left;
outline: none;
}
.accordion {
background-color: #eee;
color: #444;
Expand Down Expand Up @@ -581,24 +590,28 @@
<a href="#" id="toTopBtn" class="cd-top text-replace js-cd-top cd-top--is-visible cd-top--fade-out" data-abc="true"></a>
<div>
<header class="piranha-header">
<div class="col-sm-4" style="text-align: left;">
<img class="piranha-logo" src="https://raw.githubusercontent.com/aineniamh/piranha/main/docs/poseco.svg" vertical-align="left" width="30" height="30"></img>
<div class="col-sm-4" style="text-align: left;"><a href="https://polionanopore.org/">
<img class="piranha-logo" src="https://raw.githubusercontent.com/aineniamh/piranha/main/docs/poseco.svg" vertical-align="left" width="30" height="30"></img></a>
PoSeCo | <small class="text-muted">${LANGUAGE_CONFIG["2"]}</small>
</div>
<div class="col-sm-8" style="text-align: right;">
piranha | <small class="text-muted">${LANGUAGE_CONFIG["3"]}</small>
<div class="col-sm-8" style="text-align: right;"><a href="https://github.com/polio-nanopore/piranha/">
<strong style="color:#000"> piranha | </strong> <small class="text-muted">${LANGUAGE_CONFIG["3"]}</small></a>
</div>
<br>
<hr>
</header>

<h1>${LANGUAGE_CONFIG["4"]} ${run_name} <small class="text-muted" style="color:${themeColor}">${date}</small></h1>
<br>
%if config["username"]!="":
<h3><strong>${LANGUAGE_CONFIG["5"]}</strong> | ${config["username"].lstrip("'").rstrip("'")}</h3>
%endif
%if config["institute"]!="":
<h3><strong>${LANGUAGE_CONFIG["6"]}</strong> | ${config["institute"].lstrip("'").rstrip("'")}</h3>
%endif
<div class="info_box">
<p>${LANGUAGE_CONFIG["52"]}</p>
</div>
<br>
%if flagged_high_npev and config["sample_type"]=="environmental":
<h3><strong>${LANGUAGE_CONFIG["7"]}</strong> | ${LANGUAGE_CONFIG["8"]}</h3>
Expand Down Expand Up @@ -1007,6 +1020,12 @@
});
}
</script>
<div id="citation_box" class="info_box">
<p>${LANGUAGE_CONFIG["53"]}</p>
<p>
<strong>O’Toole Á, Colquhoun R, Ansley C, Troman C, Maloney D, Vance Z, Akello J, Bujaki E, Majumdar M, Khurshid A, Arshad Y, Alam MM, Martin J, Shaw A, Grassly N, Rambaut A</strong> (2023) Automated detection and classification of polioviruses from nanopore sequencing reads using piranha. <i>bioRxiv</i> <a style='color:#e68781' href="https://doi.org/10.1101/2023.09.05.556319">https://doi.org/10.1101/2023.09.05.556319</a>
</p>
</div>
<footer class="page-footer">
<div class="container-fluid text-right text-md-right">
<hr>
Expand Down
63 changes: 53 additions & 10 deletions piranha/input_parsing/initialising.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def get_defaults():
KEY_RUN_PHYLO:False,
KEY_CLUSTERS:[],
KEY_ANNOTATIONS:"",
KEY_TREE_ANNOTATIONS:"source ",
KEY_TREE_ANNOTATIONS:VALUE_TREE_ANNOTATIONS,
KEY_SAMPLE_SEQS:"",
KEY_PHYLO_METADATA_COLUMNS:VALUE_PHYLO_METADATA_COLUMNS,
KEY_SUPPLEMENTARY_METADATA_COLUMNS:VALUE_SUPPLEMENTARY_METADATA_COLUMNS,
Expand All @@ -62,7 +62,7 @@ def get_defaults():
# misc defaults
KEY_ORIENTATION:VALUE_ORIENTATION,
KEY_LANGUAGE:VALUE_LANGUAGE,
KEY_RUN_NAME:VALUE_RUN_NAME,
KEY_RUNNAME:VALUE_RUNNAME,
KEY_USERNAME:"",
KEY_POSITIVE:VALUE_POSITIVE,
KEY_NEGATIVE:VALUE_NEGATIVE,
Expand All @@ -81,19 +81,53 @@ def valid_args():
return [
KEY_READDIR,
KEY_BARCODES_CSV,

KEY_OUTDIR,
KEY_OUTPUT_PREFIX,
KEY_PUBLISHDIR,
KEY_TEMPDIR,
KEY_NO_TEMP,
KEY_DATESTAMP,
KEY_OVERWRITE,

KEY_SAMPLE_TYPE,
KEY_ANALYSIS_MODE,

KEY_MIN_READ_LENGTH,
KEY_MAX_READ_LENGTH,
KEY_MIN_READS,
KEY_MIN_PCENT,
KEY_MIN_MAP_QUALITY,
KEY_MIN_ALN_BLOCK,
KEY_PRIMER_LENGTH,

KEY_OUTPUT_REPORT,

KEY_REFERENCE_SEQUENCES,
KEY_REFERENCES_FOR_CNS,
KEY_MEDAKA_MODEL,

KEY_RUN_PHYLO,
KEY_SUPPLEMENTARY_SEQUENCES,
KEY_SUPPLEMENTARY_METADATA,
KEY_SUPPLEMENTARY_METADATA_ID_COLUMN,
KEY_TREE_ANNOTATIONS,
KEY_SUPPLEMENTARY_METADATA_COLUMNS,

KEY_POSITIVE,
KEY_NEGATIVE,
KEY_ORIENTATION,
KEY_DETAILED_TABLE_HEADER,

KEY_USERNAME,
KEY_INSTITUTE,
KEY_RUNNAME,

KEY_THREADS,
KEY_VERBOSE,
KEY_REFERENCE_SEQUENCES,
KEY_REFERENCES_FOR_CNS
KEY_COLOUR_MAP,
KEY_COLOUR_THEME,
KEY_LANGUAGE
]


Expand Down Expand Up @@ -137,7 +171,15 @@ def load_yaml(f):
return input_config

def return_path_keys():
return [KEY_READDIR,KEY_OUTDIR,KEY_TEMPDIR]
return [KEY_READDIR,
KEY_OUTDIR,
KEY_TEMPDIR,
KEY_PUBLISHDIR,
KEY_BARCODES_CSV,
KEY_REFERENCE_SEQUENCES,
KEY_SUPPLEMENTARY_SEQUENCES,
KEY_SUPPLEMENTARY_METADATA
]

def setup_absolute_paths(path_to_file,value):
return os.path.join(path_to_file,value)
Expand All @@ -149,7 +191,7 @@ def parse_yaml_file(configfile,configdict):

path_to_file = os.path.abspath(os.path.dirname(configfile))
configdict[KEY_INPUT_PATH] = path_to_file
valid_keys = valid_args()
valid_keys = [k for k in globals().values() if type(k)==str]
ignore_keys = ignore_args(configdict, valid_keys)

invalid_keys = []
Expand All @@ -165,9 +207,10 @@ def parse_yaml_file(configfile,configdict):
clean_key = key.lstrip("-").replace("-","_").rstrip(" ").lstrip(" ").lower()

if clean_key not in valid_keys:
if clean_key in ignore_keys:
ignored_keys.append(key)
continue
print(valid_keys)
# if clean_key in ignore_keys:
# ignored_keys.append(key)
# continue
invalid_keys.append(key)
break

Expand Down Expand Up @@ -212,7 +255,7 @@ def misc_args_to_config(verbose,threads,username,institute,run_name,config):
misc.add_arg_to_config(KEY_THREADS,threads,config)
misc.add_arg_to_config(KEY_USERNAME,username,config)
misc.add_arg_to_config(KEY_INSTITUTE,institute,config)
misc.add_arg_to_config(KEY_RUN_NAME,run_name,config)
misc.add_arg_to_config(KEY_RUNNAME,run_name,config)

def set_up_verbosity(config):
if config[KEY_VERBOSE]:
Expand Down
2 changes: 1 addition & 1 deletion piranha/report/make_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,7 @@ def make_output_report(report_to_generate,barcodes_csv,preprocessing_summary,sam

ctx = Context(buf,
date = date.today(),
run_name=config[KEY_RUN_NAME],
run_name=config[KEY_RUNNAME],
version = __version__,
show_control_table = show_control_table,
plate_json = plate_json,
Expand Down
7 changes: 5 additions & 2 deletions piranha/utils/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@
# MISC KEYS
KEY_USERNAME="username"
KEY_INSTITUTE="institute"
KEY_RUN_NAME="run_name"
KEY_RUNNAME="runname"
KEY_VERBOSE="verbose"
KEY_THREADS="threads"
KEY_LOG_API="log_api"
Expand Down Expand Up @@ -164,10 +164,13 @@
# report defaults
VALUE_ORIENTATION="vertical"
VALID_ORIENTATION=["vertical","horizontal"]
VALUE_RUN_NAME="Nanopore"
VALUE_RUNNAME="Nanopore"
VALUE_COLOUR_MAP=["#e68781","#476970","#fbedac"]
VALUE_COLOUR_THEME="#e68781"

# phylo defaults
VALUE_TREE_ANNOTATIONS="source "

#file headers
VARIANT_CALLS_HEADER_FIELDS = ["barcode","reference","variant_count","variants"]
SAMPLE_SUMMARY_TABLE_HEADER_FIELDS = ["sample","barcode","Sample classification","reference_group","Number of mutations"]
Expand Down
10 changes: 7 additions & 3 deletions piranha/utils/report_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@
"48" : "Export image",
"49" : "snipit plot for queries in",
"50" : "Co-occurrence matrix of Reference and Variant alleles called against",
"51" : ". This is the percentage of bases that cover those sites in the mapping file that are of a high quality (>13) and that are either the reference allele or the allele of the variant called at that site."
"51" : ". This is the percentage of bases that cover those sites in the mapping file that are of a high quality (>13) and that are either the reference allele or the allele of the variant called at that site.",
"52" : "This report is generated by <strong>piranha</strong>, a software tool developed to help standardise and streamline the analysis of poliovirus sequencing reads. It has been developed by members of the Rambaut group at the University of Edinburgh as part of the Poliovirus Sequencing Consortium. If you have used piranha in your work, please <a href='#citation_box' style='color:#e68781'><strong>cite</strong></a> the software.",
"53" : "General citation for Piranha"
}

# FRENCH REPORT
Expand Down Expand Up @@ -112,5 +114,7 @@
"48" : "Exporter une image",
"49" : "Graphique d'extraits pour les requêtes dans",
"50" : "Matrice de cooccurrence des allèles de référence et de variante appelée par rapport à la référence",
"51" : ". Il s'agit du pourcentage de bases qui couvrent les sites du fichier de cartographie qui sont de haute qualité (>13) et qui sont soit l'allèle de référence, soit l'allèle du variant appelé sur ce site."
}
"51" : ". Il s'agit du pourcentage de bases qui couvrent les sites du fichier de cartographie qui sont de haute qualité (>13) et qui sont soit l'allèle de référence, soit l'allèle du variant appelé sur ce site.",
"52" : "Ce rapport est généré par piranha, un outil logiciel développé pour aider à standardiser et rationaliser l'analyse des lectures de séquençage du poliovirus. Il a été développé par des membres du groupe Rambaut de l'Université d'Édimbourg dans le cadre du Poliovirus Sequencing Consortium. Si vous avez utilisé piranha dans votre travail, merci de <a href='#citation_box' style='color:#e68781'><strong>citer</strong></a> le logiciel.",
"53" : "Citation générale pour Piranha"
}

0 comments on commit 3b8507f

Please sign in to comment.