pulsatrix 1.1.0
Loading...
Searching...
No Matches
protein_documents.hpp
Go to the documentation of this file.
1
11#pragma once
12
13#include <cstdint>
14#include <string>
15#include <string_view>
16#include <vector>
17
21
22namespace pulsatrix {
23
24// ---- mutation map --------------------------------------------------------------------------
25
32 std::string title;
34 std::string method;
36 std::string sequence;
38 int64_t first_position = 1;
40 std::string alphabet = kAminoAcids;
42 std::vector<float> values;
43};
44
49[[nodiscard]] MutationMapDocument MakeMutationMapDocument(std::string_view sequence, const std::vector<float>& scan,
50 std::string method = "", int64_t first_position = 1);
53[[nodiscard]] std::string ToJson(const MutationMapDocument& doc);
54[[nodiscard]] MutationMapDocument ParseMutationMapDocument(std::string_view json);
55
56// ---- sequence logo -------------------------------------------------------------------------
57
63 std::string title;
64 std::string method;
66 std::string sequence;
67 int64_t first_position = 1;
68 std::string alphabet = kAminoAcids;
71 std::vector<float> probabilities;
72
73 [[nodiscard]] int64_t positions() const;
74};
75
83[[nodiscard]] SequenceLogoDocument MakeSequenceLogoDocument(const ResidueLogProbs& log_probs, const TextTokenizer& tokenizer,
84 std::string_view sequence, std::string method = "",
85 int64_t first_position = 1);
91[[nodiscard]] std::vector<float> InformationContent(const SequenceLogoDocument& doc);
95[[nodiscard]] std::string ToJson(const SequenceLogoDocument& doc);
96[[nodiscard]] SequenceLogoDocument ParseSequenceLogoDocument(std::string_view json);
97
98// ---- contact map ---------------------------------------------------------------------------
99
106 std::string title;
107 std::string method;
108 std::string sequence;
109 int64_t first_position = 1;
111 std::vector<float> predicted;
113 std::vector<float> truth;
114
115 [[nodiscard]] int64_t length() const { return static_cast<int64_t>(sequence.size()); }
116};
117
122[[nodiscard]] ContactMapDocument MakeContactMapDocument(std::string_view sequence, const ContactMap& predicted,
123 const ContactMap* truth = nullptr, std::string method = "",
124 int64_t first_position = 1);
127[[nodiscard]] std::string ToJson(const ContactMapDocument& doc);
128[[nodiscard]] ContactMapDocument ParseContactMapDocument(std::string_view json);
129
130// ---- residue tracks ------------------------------------------------------------------------
131
138 std::string title;
139 std::string sequence;
140 int64_t first_position = 1;
141 struct Track {
142 std::string name;
144 std::vector<float> values;
147 bool is_signed = false;
148 };
149 std::vector<Track> tracks;
152 struct Feature {
153 std::string name;
154 int64_t start = 0;
155 int64_t end = 0;
157 std::string category;
158 };
159 std::vector<Feature> features;
165 std::vector<std::string> residue_ids;
166};
167
170[[nodiscard]] std::vector<float> MeanSubstitutionScore(const MutationMapDocument& doc);
172[[nodiscard]] std::vector<std::string> ResidueIds(const StructureChain& chain);
176[[nodiscard]] std::string ToJson(const ResidueTracksDocument& doc);
177[[nodiscard]] ResidueTracksDocument ParseResidueTracksDocument(std::string_view json);
178
179} // namespace pulsatrix
A tokenizer: added tokens are split out of the raw text first (longest match, earliest first); each r...
Definition text_tokenizer.hpp:166
Definition acquisition_functions.hpp:16
ContactMapDocument 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::vector< std::string > ResidueIds(const StructureChain &chain)
chain's residue ids, for ResidueTracksDocument::residue_ids.
SequenceLogoDocument 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): eac...
ContactMapDocument ParseContactMapDocument(std::string_view json)
std::vector< float > InformationContent(const SequenceLogoDocument &doc)
Each position's information content in bits, log2(letters) - entropy: 0 when every letter is equally ...
JsonValue ToJson(const AttackResult &result, const AttackOptions &options)
The result as a pulsatrix.attack.v1 document, without the adversarial inputs.
MutationMapDocument 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).
ResidueTracksDocument ParseResidueTracksDocument(std::string_view json)
SequenceLogoDocument ParseSequenceLogoDocument(std::string_view json)
MutationMapDocument ParseMutationMapDocument(std::string_view json)
constexpr const char * kAminoAcids
The 20 standard amino acids, in the order SingleMutantScan's columns use.
Definition variant_scoring.hpp:47
std::vector< float > MeanSubstitutionScore(const MutationMapDocument &doc)
Each residue's mean score over its substitutions (the wild type left out): how much the model minds a...
Protein structures (PLM-4): PDB and mmCIF coordinates, residue distances and true contacts,...
pulsatrix.contact_map.v1: predicted contacts between a sequence's residues, and the true ones when a ...
Definition protein_documents.hpp:105
int64_t first_position
Definition protein_documents.hpp:109
std::string sequence
Definition protein_documents.hpp:108
std::vector< float > truth
Empty, or L x L: 1 for a contact, 0 for none, NaN where unknown.
Definition protein_documents.hpp:113
int64_t length() const
Definition protein_documents.hpp:115
std::string title
Definition protein_documents.hpp:106
std::string method
Definition protein_documents.hpp:107
std::vector< float > predicted
L x L scores, higher meaning more likely in contact, such as probabilities.
Definition protein_documents.hpp:111
A square matrix over a sequence's residue pairs, row-major: predicted contact probabilities,...
Definition protein_structure.hpp:85
pulsatrix.mutation_map.v1: a score for every substitution, residue by residue, such as a model's log-...
Definition protein_documents.hpp:31
std::string title
Definition protein_documents.hpp:32
std::vector< float > values
Row-major (residues, alphabet). NaN marks a substitution that wasn't scored.
Definition protein_documents.hpp:42
std::string alphabet
The substitutions scored at each residue, one letter each: the columns of values.
Definition protein_documents.hpp:40
std::string sequence
The wild-type sequence, one letter per residue.
Definition protein_documents.hpp:36
int64_t first_position
The number of the sequence's first residue.
Definition protein_documents.hpp:38
std::string method
How the scores were made, for example "masked_marginals". Optional.
Definition protein_documents.hpp:34
Log-probabilities of every token at each residue: length rows of vocab values.
Definition variant_scoring.hpp:39
An annotated stretch: positions start to end inclusive, in the document's numbering.
Definition protein_documents.hpp:152
std::string name
Definition protein_documents.hpp:153
int64_t start
Definition protein_documents.hpp:154
int64_t end
Definition protein_documents.hpp:155
std::string category
What kind of feature, such as "domain" or "site"; one row per category.
Definition protein_documents.hpp:157
Definition protein_documents.hpp:141
std::vector< float > values
One value per residue; NaN where there is none.
Definition protein_documents.hpp:144
std::string name
Definition protein_documents.hpp:142
bool is_signed
Signed values are drawn on a diverging scale around zero, others from zero up. A reader treats a miss...
Definition protein_documents.hpp:147
pulsatrix.residue_tracks.v1: per-residue signals stacked under a sequence, and annotated stretches (d...
Definition protein_documents.hpp:137
std::vector< std::string > residue_ids
Empty, or each residue's id in a structure: the author's number and insertion code,...
Definition protein_documents.hpp:165
std::vector< Feature > features
Definition protein_documents.hpp:159
int64_t first_position
Definition protein_documents.hpp:140
std::string title
Definition protein_documents.hpp:138
std::string sequence
Definition protein_documents.hpp:139
std::vector< Track > tracks
Definition protein_documents.hpp:149
pulsatrix.sequence_logo.v1: a distribution over letters at each residue, such as what a masked langua...
Definition protein_documents.hpp:62
std::string alphabet
Definition protein_documents.hpp:68
int64_t first_position
Definition protein_documents.hpp:67
std::string title
Definition protein_documents.hpp:63
std::vector< float > probabilities
Row-major (positions, alphabet); each row is a distribution (non-negative, summing to 1 within 1e-3).
Definition protein_documents.hpp:71
std::string sequence
The sequence the distributions belong to (its letters are marked), or empty.
Definition protein_documents.hpp:66
std::string method
Definition protein_documents.hpp:64
A chain's residues, in file order.
Definition protein_structure.hpp:39
The tokenizer interface (TOK-1): a pipeline of normalizer, pre-tokenizer, model, post-processor and d...
Zero-shot variant effects from a protein language model (PLM-3): how much the model prefers a mutant ...