pulsatrix 1.1.0
Loading...
Searching...
No Matches
protein_documents.hpp File Reference

Viz documents for proteins (PLM-5): the mutation map, the sequence logo, the contact map and residue tracks, with builders from a protein language model's outputs. More...

#include <cstdint>
#include <string>
#include <string_view>
#include <vector>
#include "pulsatrix/protein_structure.hpp"
#include "pulsatrix/text_tokenizer.hpp"
#include "pulsatrix/variant_scoring.hpp"
Include dependency graph for protein_documents.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  pulsatrix::MutationMapDocument
 pulsatrix.mutation_map.v1: a score for every substitution, residue by residue, such as a model's log-odds log p(mutant) - log p(wild type) or a deep mutational scan's measurements. More...
 
struct  pulsatrix::SequenceLogoDocument
 pulsatrix.sequence_logo.v1: a distribution over letters at each residue, such as what a masked language model predicts there, drawn as a sequence logo. More...
 
struct  pulsatrix::ContactMapDocument
 pulsatrix.contact_map.v1: predicted contacts between a sequence's residues, and the true ones when a structure is known. Drawn as one square: predictions above the diagonal, the structure below it, with the best predictions marked right or wrong. More...
 
struct  pulsatrix::ResidueTracksDocument
 pulsatrix.residue_tracks.v1: per-residue signals stacked under a sequence, and annotated stretches (domains, sites), as in a genome or protein browser. The same document colors a 3D structure (RenderStructureHtml). More...
 
struct  pulsatrix::ResidueTracksDocument::Track
 
struct  pulsatrix::ResidueTracksDocument::Feature
 An annotated stretch: positions start to end inclusive, in the document's numbering. More...
 

Namespaces

namespace  pulsatrix
 

Functions

MutationMapDocument pulsatrix::MakeMutationMapDocument (std::string_view sequence, const std::vector< float > &scan, std::string method="", int64_t first_position=1)
 A mutation map from VariantScorer::single_mutant_scan (L x 20, in kAminoAcids order).
 
std::string pulsatrix::ToJson (const MutationMapDocument &doc)
 
MutationMapDocument pulsatrix::ParseMutationMapDocument (std::string_view json)
 
SequenceLogoDocument pulsatrix::MakeSequenceLogoDocument (const ResidueLogProbs &log_probs, const TextTokenizer &tokenizer, std::string_view sequence, std::string method="", int64_t first_position=1)
 A logo from a model's log-probabilities (VariantScorer::masked_marginals or wild_type_marginals): each residue's probabilities over the 20 amino acids, renormalized to sum to 1 (special and rare tokens dropped).
 
std::vector< float > pulsatrix::InformationContent (const SequenceLogoDocument &doc)
 Each position's information content in bits, log2(letters) - entropy: 0 when every letter is equally likely, log2(20) (4.32) when one is certain. A logo stacks the letters to this height, each in proportion to its probability.
 
std::string pulsatrix::ToJson (const SequenceLogoDocument &doc)
 
SequenceLogoDocument pulsatrix::ParseSequenceLogoDocument (std::string_view json)
 
ContactMapDocument pulsatrix::MakeContactMapDocument (std::string_view sequence, const ContactMap &predicted, const ContactMap *truth=nullptr, std::string method="", int64_t first_position=1)
 Pairs a prediction with the structure's contacts (TrueContacts), if any.
 
std::string pulsatrix::ToJson (const ContactMapDocument &doc)
 
ContactMapDocument pulsatrix::ParseContactMapDocument (std::string_view json)
 
std::vector< float > pulsatrix::MeanSubstitutionScore (const MutationMapDocument &doc)
 Each residue's mean score over its substitutions (the wild type left out): how much the model minds a change there. NaN where none was scored.
 
std::vector< std::string > pulsatrix::ResidueIds (const StructureChain &chain)
 chain's residue ids, for ResidueTracksDocument::residue_ids.
 
std::string pulsatrix::ToJson (const ResidueTracksDocument &doc)
 
ResidueTracksDocument pulsatrix::ParseResidueTracksDocument (std::string_view json)
 

Detailed Description

Viz documents for proteins (PLM-5): the mutation map, the sequence logo, the contact map and residue tracks, with builders from a protein language model's outputs.

They follow the rules of every viz document (document.hpp): a "schema" of pulsatrix.<kind>.v1, non-finite numbers as null plus a "nonfinite" entry, and readers that name the JSON Pointer of the first problem. Positions are residues of one sequence, numbered from first_position (1 unless the sequence is a fragment), as variant tables number them.