Package: pypresident
PRESIDENT: PaiRwisE Sequence IDENtiTyCalculate pairwise nucleotide identity with respect to a reference sequence.Given a reference and a query sequence, calculate pairwise nucleotide identity with respect to the reference sequence relative to the entire length of the reference. In the main metric, only informative nucleotides (A, T, G, C) are considered identical to each other. The tool also provides some further metrics (e.g. regarding ambiguous 'N's) and splits the input FASTA intovalidandfailedFASTA files for further processing.Installation:To install president with conda, run the commands below:conda create -y -n president -c bioconda -c conda-forge president
conda activate presidentNote thatpblatis a dependency and only runs on Linux. Alternatively, president can be installed with pip in an environment where pblat is in the PATH:pip install pypresidentAnother possibility is to use a docker image with all dependencies installed:docker pull rkibioinf/president:latestUsage:The pairwise alignment can be run with the following console call:president --query query.fasta --reference reference.fasta -x identity_threshold -n n_threshold -t threads -p /path/to/output/ -f prefixTo run an example, download aqueryFASTA and
areferenceFASTA from GitLab.Run the alignment with the following command and identity of ACGT bases of 90% and maximal 5% Ns in the query. Note that multiple fasta sequences are allowed to be present in the query butnotin the reference FASTA.president -q NC_045512.2.20mis.fasta -r NC_045512.2.fasta -x 0.9 -n 0.05 -t 4 -p output/ -f test_Output:The script provides:a tab-separated file with the below listed columnsa FASTA file withvalidsequencesa FASTA file withinvalidsequencesThe separation between thevalidandinvalidbin is mainly based on the defined identity/n thresholds (-x, default: 0.9;-n, default: 0.05) and further sanity checks (non-IUPAC characters).
Note that for multiple query inputs the valid and invalid sequence headers are NOT associate with their filename. This meta information must be retrieved from the report.
An example from the call described above can be foundonline.Attention: If your query sequence includes gap symbols (-or.; for example from a previous alignment step),presidentwillremovethem from the output sequence! Rational: Gap symbols should be not part of a consensus sequence (for which the tool was developed) and will therefore be removed.Until version 0.6.7 gap symbols were replaced withN!The transposed version of the output is shown below.variablevaluequery_nameNC_045512.2 Severe acute [...]reference_nameNC_045512.2 Severe acute [...]file_in_queryNC_045512.2.20mis.fastafile_in_refNC_045512.2.fastaACGT Nucleotide identity0.9987ACGT Nucleotide identity (ignoring Ns)0.9994ACGT Nucleotide identity (ignoring non-ACGTNs)0.9994qc_all_validTrueqc_is_empty_queryFalseqc_post_align_pass_thresholdTrueqc_post_alignedTrueqc_post_aligned_all_validTrueqc_valid_lengthTrueqc_valid_nucleotidesTrueqc_valid_pass_nthresholdTrueacgt_bases29883iupac_bases20non_iupac_bases0N_bases20length_query29903length_reference29903LongestNGap20Matches29864Mismatches19query_descriptionquery_index0Date2021-01-20Definitions:query_name - FASTA ID of the query sequence + file origin, format :reference_name - FASTA ID of the reference sequencefile_in_query - the input query file namefile_in_ref - the input reference file name (note that for multiple input queries a tempororay file name is reported)ACGT Nucleotide identity - Percentage of ACGT matches to the reference (# matches / max(sequence_lengths))ACGT Nucleotide identity (ignoring Ns) - Percentage of ACGT matches to the reference (# matches / max(sequence_lengths) - #Ns in query)ACGT Nucleotide identity (ignoring non-ACGTNs) - Percentage of ACGT matches to the reference (# matches / max(sequence_lengths) - #non-ACGTNs in query)qc_all_valid - True if all checks below are Trueqc_is_empty_query - True if input query file is not emptyqc_post_align_pass_threshold - True if 'ACGT Nucleotide identity' is greater than the-xparameterqc_post_aligned - Set to True if the sequence was aligned (can be False either because of initial checks or failed alignments)qc_post_aligned_all_valid - True if all checks before alignment are True, alignment is only performed if this value is Trueqc_valid_length - True if the query is actually able to achieve the-xscore even if the query is shorter/ longerqc_valid_nucleotides - True if only valid IUPAC characters are in the queryqc_valid_pass_nthreshold - True if-npercentage of Ns in the query is not exceededacgt_bases - number of ACGT basesiupac_bases - number of IUPAC basesnon_iupac_bases - Number of non-IUPAC nucleotides in the queryN_bases - the number of N baseslength_query - the length of the querylength_reference - the length of the referenceLongestNGap - Lenght of the longest N gapMatches - the number of matches in the alignmentMismatches - the number of mismatches in the alignmentquery_description - query description, if availablequery_index - the position of the sequence in the query fasta input file (for multiple files the counter is not resetted)Date - the yyyy-mm-dd of the execution of the scriptNote: max(sequence_lengths) is equal to max(length_query, length_reference).Notes:nextstrain uses a quality threshold of < 3000 non-canonical nucleotidesANI definition:https://pubmed.ncbi.nlm.nih.gov/17220447/ContributingIf you would like to get involved, here is information oncontribution guidelines and how to test the code locally.You can contribute in multiple ways, e.g., reporting bugs, reviewing or refactoring code, requesting or implementing new features, etc.