use crate::biblio::{PubMedId, DOI};
use crate::general::{DbTag, IntFuzz, ObjectId, UserObject};
use crate::parsing::{read_vec_node, read_int, read_node, read_string, read_vec_str_unchecked, UnexpectedTags, read_bool_attribute};
use crate::r#pub::PubSet;
use crate::seq::{Heterogen, Numbering, PubDesc, SeqLiteral};
use crate::seqloc::{GiimportId, SeqId, SeqLoc};
use crate::parsing::{XmlNode, XmlVecNode};
use bitflags::bitflags;
use enum_primitive::FromPrimitive;
use quick_xml::events::{BytesStart, Event};
use quick_xml::Reader;
use serde::{Deserialize, Serialize};
use serde_repr::{Deserialize_repr, Serialize_repr};
#[derive(Clone, Serialize, Deserialize, PartialEq, Debug)]
#[serde(rename_all = "lowercase")]
pub enum FeatId {
GIBB(u64),
GIIM(GiimportId),
Local(ObjectId),
General(DbTag),
}
impl XmlNode for FeatId {
fn start_bytes() -> BytesStart<'static> {
BytesStart::new("Feat-id")
}
fn from_reader(reader: &mut Reader<&[u8]>) -> Option<Self> where Self: Sized {
let gibb_tag = BytesStart::new("Feat-id_gibb");
let giim_tag = BytesStart::new("Feat-id_giim");
let local_tag = BytesStart::new("Feat-id_local");
let general_tag = BytesStart::new("Feat-id_general");
let forbidden = [
gibb_tag,
giim_tag
];
let forbidden = UnexpectedTags(&forbidden);
loop {
match reader.read_event().unwrap() {
Event::Start(e) => {
let name = e.name();
if name == local_tag.name() {
return Self::Local(read_node(reader).unwrap()).into();
} else if name == general_tag.name() {
return Self::General(read_node(reader).unwrap()).into();
} else if name != Self::start_bytes().name() {
forbidden.check(&name);
}
}
Event::End(e) => {
if Self::is_end(&e) {
return None
}
}
_ => ()
}
}
}
}
#[derive(Clone, Serialize_repr, Deserialize_repr, PartialEq, Debug)]
#[repr(u8)]
pub enum SeqFeatExpEvidence {
Experimental = 1,
NotExperimental,
}
#[derive(Clone, Serialize, Deserialize, PartialEq, Debug)]
#[serde(rename_all = "kebab-case")]
pub struct SeqFeat {
pub id: Option<FeatId>,
pub data: SeqFeatData,
pub partial: Option<bool>,
pub except: Option<bool>,
pub comment: Option<String>,
pub product: Option<SeqLoc>,
pub location: SeqLoc,
pub qual: Option<Vec<GbQual>>,
pub title: Option<String>,
pub ext: Option<UserObject>,
pub cit: Option<PubSet>,
pub exp_ev: Option<SeqFeatExpEvidence>,
pub xref: Option<Vec<SeqFeatXref>>,
pub dbxref: Option<Vec<DbTag>>,
pub pseudo: Option<bool>,
pub except_text: Option<String>,
pub ids: Option<Vec<FeatId>>,
pub exts: Option<Vec<UserObject>>,
pub support: Option<SeqFeatSupport>,
}
impl SeqFeat {
pub fn default() -> Self {
Self::new(SeqFeatData::User(UserObject::default()))
}
pub fn new(data: SeqFeatData) -> Self {
Self {
id: None,
data,
partial: None,
except: None,
comment: None,
product: None,
location: SeqLoc::default(),
qual: None,
title: None,
ext: None,
cit: None,
exp_ev: None,
xref: None,
dbxref: None,
pseudo: None,
except_text: None,
ids: None,
exts: None,
support: None,
}
}
}
impl XmlNode for SeqFeat {
fn start_bytes() -> BytesStart<'static> {
BytesStart::new("Seq-feat")
}
fn from_reader(reader: &mut Reader<&[u8]>) -> Option<Self> where Self: Sized {
let mut feat = Self::default();
let id_tag = BytesStart::new("Seq-feat_id");
let data_tag = BytesStart::new("Seq-feat_data");
let partial_tag = BytesStart::new("Seq-feat_partial");
let except_tag = BytesStart::new("Seq-feat_except");
let comment_tag = BytesStart::new("Seq-feat_comment");
let product_tag = BytesStart::new("Seq-feat_product");
let location_tag = BytesStart::new("Seq-feat_location");
let qual_tag = BytesStart::new("Seq-feat_qual");
let title_tag = BytesStart::new("Seq-feat_title");
let ext_tag = BytesStart::new("Seq-feat_ext");
let cit_tag = BytesStart::new("Seq-feat_cit");
let exp_ev_tag = BytesStart::new("Seq-feat_exp_ev");
let xref_tag = BytesStart::new("Seq-feat_xref");
let dbxref_tag = BytesStart::new("Seq-feat_db_xref");
let pseudo_tag = BytesStart::new("Seq-feat_pseudo");
let except_text_tag = BytesStart::new("Seq-feat_except_text");
let ids_tag = BytesStart::new("Seq-feat_ids");
let exts_tag = BytesStart::new("Seq-feat_exts");
let support_tag = BytesStart::new("Seq-feat_support");
let forbidden = [
partial_tag,
except_tag,
title_tag,
cit_tag,
exp_ev_tag,
dbxref_tag,
except_text_tag,
ids_tag,
exts_tag,
support_tag
];
let forbidden = UnexpectedTags(&forbidden);
loop {
match reader.read_event().unwrap() {
Event::Start(e) => {
let name = e.name();
if name == id_tag.name() {
feat.id = read_node(reader);
} else if name == ext_tag.name() {
feat.ext = read_node(reader);
} else if name == product_tag.name() {
feat.product = read_node(reader);
} else if name == qual_tag.name() {
feat.qual = Some(read_vec_node(reader, qual_tag.to_end()));
} else if name == data_tag.name() {
feat.data = read_node(reader).unwrap();
} else if name == location_tag.name() {
feat.location = read_node(reader).unwrap();
} else if name == comment_tag.name() {
feat.comment = read_string(reader);
} else if name == xref_tag.name() {
feat.xref = Some(read_vec_node(reader, xref_tag.to_end()));
} else if name != Self::start_bytes().name() {
forbidden.check(&name);
}
}
Event::Empty(e) => {
if e.name() == pseudo_tag.name() {
feat.pseudo = read_bool_attribute(&e);
}
}
Event::End(e) => {
if Self::is_end(&e) {
return feat.into()
}
}
_ => ()
}
}
}
}
impl XmlVecNode for SeqFeat {}
#[derive(Clone, Serialize_repr, Deserialize_repr, PartialEq, Debug)]
#[repr(u8)]
pub enum SeqFeatBond {
Disulfide = 1,
Thiolester,
XLink,
Thioether,
Other = 255,
}
#[derive(Clone, Serialize_repr, Deserialize_repr, PartialEq, Debug)]
#[repr(u8)]
pub enum SeqFeatSite {
Active = 1,
Binding,
Cleavage,
Inhibit,
Modified,
Clycosylation,
Myristoylation,
Mutagenized,
MetalBinding,
Phosphorylation,
Acetylation,
Amidation,
Methylation,
Hydroxylation,
Sulfatation,
OxidativeDeamination,
PyrrolidoneCarboxylicAcid,
GammaCarboxylglutamicAcid,
Blocked,
LipidBinding,
NpBinding,
DnaBinding,
SignalPeptide,
TransitPeptide,
TransmembraneRegion,
Nitrosylation,
Other = 255,
}
#[derive(Clone, Serialize_repr, Deserialize_repr, PartialEq, Debug)]
#[repr(u8)]
pub enum PSecStr {
Helix = 1,
Sheet,
Turn,
}
#[derive(Clone, Serialize, Deserialize, PartialEq, Debug)]
#[serde(rename_all = "lowercase")]
pub enum SeqFeatData {
Gene(GeneRef),
Org(OrgRef),
CdRegion(CdRegion),
Prot(ProtRef),
RNA(RnaRef),
Pub(PubDesc),
Seq(SeqLoc),
Imp(ImpFeat),
Region(String),
Bond(SeqFeatBond),
Site(SeqFeatSite),
RSite(RSiteRef),
User(UserObject),
TxInit(TxInit),
Num(Numbering),
#[serde(rename = "psec-str")]
PSecStr(PSecStr),
#[serde(rename = "non-std-residue")]
NonStdResidue(String),
Het(Heterogen),
BioSrc(BioSource),
Clone(CloneRef),
Variation(VariationRef),
}
impl XmlNode for SeqFeatData {
fn start_bytes() -> BytesStart<'static> {
BytesStart::new("SeqFeatData")
}
fn from_reader(reader: &mut Reader<&[u8]>) -> Option<Self> where Self: Sized {
let gene_tag = BytesStart::new("SeqFeatData_gene");
let org_tag = BytesStart::new("SeqFeatData_org");
let cdregion_tag = BytesStart::new("SeqFeatData_cdregion");
let prot_tag = BytesStart::new("SeqFeatData_prot");
let rna_tag = BytesStart::new("SeqFeatData_rna");
let pub_tag = BytesStart::new("SeqFeatData_pub");
let seq_tag = BytesStart::new("SeqFeatData_seq");
let imp_tag = BytesStart::new("SeqFeatData_imp");
let region_tag = BytesStart::new("SeqFeatData_region");
let bond_tag = BytesStart::new("SeqFeatData_bond");
let site_tag = BytesStart::new("SeqFeatData_site");
let rsite_tag = BytesStart::new("SeqFeatData_rsite");
let user_tag = BytesStart::new("SeqFeatData_user");
let txinit_tag = BytesStart::new("SeqFeatData_txinit");
let num_tag = BytesStart::new("SeqFeatData_num");
let psec_str_tag = BytesStart::new("SeqFeatData_psec-str");
let non_std_residue_tag = BytesStart::new("SeqFeatData_non-std-residue");
let het_tag = BytesStart::new("SeqFeatData_het");
let biosrc_tag = BytesStart::new("SeqFeatData_biosrc");
let clone_tag = BytesStart::new("SeqFeatData_clone");
let variation_tag = BytesStart::new("SeqFeatData_variation");
let forbidden = [
org_tag,
rna_tag,
pub_tag,
seq_tag,
imp_tag,
region_tag,
bond_tag,
site_tag,
rsite_tag,
user_tag,
txinit_tag,
num_tag,
psec_str_tag,
non_std_residue_tag,
het_tag,
biosrc_tag,
clone_tag,
variation_tag
];
let forbidden = UnexpectedTags(&forbidden);
loop {
match reader.read_event().unwrap() {
Event::Start(e) => {
let name = e.name();
if name == gene_tag.name() {
return Self::Gene(read_node(reader).unwrap()).into()
}
else if name == cdregion_tag.name() {
return Self::CdRegion(read_node(reader).unwrap()).into()
}
else if name == prot_tag.name() {
return Self::Prot(read_node(reader).unwrap()).into();
}
else if name != Self::start_bytes().name() {
forbidden.check(&name);
}
}
Event::End(e) => {
if Self::is_end(&e) {
return None
}
}
_ => ()
}
}
}
}
#[derive(Clone, Serialize, Deserialize, PartialEq, Debug, Default)]
pub struct SeqFeatXref {
pub id: Option<FeatId>,
pub data: Option<SeqFeatData>,
}
impl XmlNode for SeqFeatXref {
fn start_bytes() -> BytesStart<'static> {
BytesStart::new("SeqFeatXref")
}
fn from_reader(reader: &mut Reader<&[u8]>) -> Option<Self> where Self: Sized {
let mut xref = Self::default();
let data_tag = BytesStart::new("SeqFeatXref_data");
let id_tag = BytesStart::new("SeqFeatXref_id");
loop {
match reader.read_event().unwrap() {
Event::Start(e) => {
let name = e.name();
if name == data_tag.name() {
xref.data = read_node(reader);
} else if name == id_tag.name() {
xref.id = read_node(reader);
}
}
Event::End(e) => {
if Self::is_end(&e) {
return xref.into()
}
}
_ => ()
}
}
}
}
impl XmlVecNode for SeqFeatXref {}
#[derive(Clone, Serialize, Deserialize, PartialEq, Debug)]
#[serde(rename_all = "kebab-case")]
pub struct SeqFeatSupport {
pub experiment: Option<Vec<ExperimentSupport>>,
pub inference: Option<Vec<InferenceSupport>>,
pub model_evidence: Option<Vec<ModelEvidenceSupport>>,
}
#[derive(Clone, Serialize_repr, Deserialize_repr, PartialEq, Debug)]
#[repr(u8)]
pub enum EvidenceCategory {
NotSet,
Coordinates,
Description,
Existence,
}
#[derive(Clone, Serialize, Deserialize, PartialEq, Debug)]
pub struct ExperimentSupport {
pub category: Option<EvidenceCategory>,
pub explanation: String,
pub pmids: Option<Vec<PubMedId>>,
pub dois: Option<Vec<DOI>>,
}
#[derive(Clone, Serialize, Deserialize, PartialEq, Debug)]
pub struct ProgramId {
pub name: String,
pub version: Option<String>,
}
#[derive(Clone, Serialize, Deserialize, PartialEq, Debug)]
pub struct EvidenceBasis {
pub programs: Option<Vec<ProgramId>>,
pub accessions: Option<Vec<SeqId>>,
}
#[derive(Clone, Serialize_repr, Deserialize_repr, PartialEq, Debug, Default)]
#[repr(u8)]
pub enum InferenceSupportType {
#[default]
NotSet,
SimilarToSequence,
SimilarToAA,
SimilarToDNA,
SimilarToRNA,
SimilarTomRNA,
SimilarToEst,
SimilarToOtherRNA,
Profile,
NucleotideMotif,
ProteinMotif,
AbInitioPrediction,
Alignment,
Other = 255,
}
#[derive(Clone, Serialize, Deserialize, PartialEq, Debug)]
#[serde(rename_all = "kebab-case")]
pub struct InferenceSupport {
pub category: Option<EvidenceCategory>,
#[serde(rename = "type")]
pub r#type: InferenceSupportType,
pub other_type: Option<String>,
pub same_species: bool,
pub basis: EvidenceBasis,
pub pmids: Option<Vec<PubMedId>>,
pub dois: Option<Vec<DOI>>,
}
#[derive(Clone, Serialize, Deserialize, PartialEq, Debug)]
#[serde(rename_all = "kebab-case")]
pub struct ModelEvidenceItem {
pub id: SeqId,
pub exon_count: Option<u64>,
pub exon_length: Option<u64>,
pub full_length: bool,
pub supports_all_exon_combo: bool,
}
#[derive(Clone, Serialize, Deserialize, PartialEq, Debug)]
#[serde(rename_all = "kebab-case")]
pub struct ModelEvidenceSupport {
pub method: Option<String>,
pub mrna: Option<Vec<ModelEvidenceItem>>,
pub est: Option<Vec<ModelEvidenceItem>>,
pub protein: Option<Vec<ModelEvidenceItem>>,
pub identification: Option<SeqId>,
pub dbxref: Option<Vec<DbTag>>,
pub exon_count: Option<u64>,
pub exon_length: Option<u64>,
pub full_length: bool, pub supports_all_exon_combo: bool, }
#[derive(Clone, Serialize_repr, Deserialize_repr, PartialEq, Debug, Default)]
#[repr(u8)]
pub enum CdRegionFrame {
#[default]
NotSet,
One,
Two,
Three,
}
#[derive(Clone, Serialize, Deserialize, PartialEq, Debug, Default)]
#[serde(rename_all = "kebab-case")]
pub struct CdRegion {
pub orf: Option<bool>,
pub frame: CdRegionFrame,
pub conflict: Option<bool>,
pub gaps: Option<u64>,
pub mismatch: Option<u64>,
pub code: Option<GeneticCode>,
pub code_break: Option<Vec<CodeBreak>>,
pub stops: Option<u64>,
}
impl XmlNode for CdRegion {
fn start_bytes() -> BytesStart<'static> {
BytesStart::new("Cdregion")
}
fn from_reader(reader: &mut Reader<&[u8]>) -> Option<Self> where Self: Sized {
let mut cdregion = Self::default();
let _orf_tag = BytesStart::new("Cdregion_orf");
let _frame_tag = BytesStart::new("Cdregion_frame");
let _conflict_tag = BytesStart::new("Cdregion_conflict");
let gaps_tag = BytesStart::new("Cdregion_gaps");
let mismatch_tag = BytesStart::new("Cdregion_mismatch");
let code_tag = BytesStart::new("Cdregion_code");
let _code_break_tag = BytesStart::new("Cdregion_code-break");
let stops_tag = BytesStart::new("Cdregion_stops");
let forbidden = UnexpectedTags(&[]);
loop {
match reader.read_event().unwrap() {
Event::Start(e) => {
let name = e.name();
if name == code_tag.name() {
cdregion.code = Some(read_vec_node(reader, code_tag.to_end()))
} else if name == gaps_tag.name() {
cdregion.gaps = read_int(reader);
} else if name == mismatch_tag.name() {
cdregion.mismatch = read_int(reader);
} else if name == stops_tag.name() {
cdregion.stops = read_int(reader);
} else if name != Self::start_bytes().name() {
forbidden.check(&name)
}
}
Event::End(e) => {
if Self::is_end(&e) {
return cdregion.into()
}
}
_ => ()
}
}
}
}
#[derive(Clone, Serialize, Deserialize, PartialEq, Debug)]
#[serde(rename_all = "lowercase")]
pub enum GeneticCodeOpt {
Name(String),
Id(u64),
NcbiEaa(String),
NCBI8aa(Vec<u8>),
NCBIStdAa(Vec<u8>),
SNcbiEaa(String),
SNcbi8aa(Vec<u8>),
SNcbiStdAa(Vec<u8>),
}
impl XmlNode for GeneticCodeOpt {
fn start_bytes() -> BytesStart<'static> {
BytesStart::new("Genetic-code_E")
}
fn from_reader(reader: &mut Reader<&[u8]>) -> Option<Self> where Self: Sized {
let id_tag = BytesStart::new("Genetic-code_E_id");
let name_tag = BytesStart::new("Genetic-code_E_name");
let ncbieaa_tag = BytesStart::new("Genetic-code_E_ncbieaa");
let ncbi8aa_tag = BytesStart::new("Genetic-code_E_ncbi8aa");
let ncbistdaa_tag = BytesStart::new("Genetic-code_E_ncbistdaa");
let sncbieaa_tag = BytesStart::new("Genetic-code_E_sncbieaa");
let sncbi8aa_tag = BytesStart::new("Genetic-code_E_sncbi8aa");
let sncbistdaa_tag = BytesStart::new("Genetic-code_E_sncbistdaa");
loop {
match reader.read_event().unwrap() {
Event::Start(e) => {
let name = e.name();
if name == id_tag.name() {
return Self::Id(read_int(reader).unwrap()).into()
}
}
Event::End(e) => {
if Self::is_end(&e) {
return None
}
}
_ => ()
}
}
}
}
impl XmlVecNode for GeneticCodeOpt {}
pub type GeneticCode = Vec<GeneticCodeOpt>;
#[derive(Clone, Serialize, Deserialize, PartialEq, Debug)]
#[serde(rename_all = "lowercase")]
pub enum CodeBreakAA {
NcbiAa(u64),
Ncbi8aa(u64),
NcbiStdAa(u64),
}
#[derive(Clone, Serialize, Deserialize, PartialEq, Debug)]
pub struct CodeBreak {
pub loc: SeqLoc,
pub aa: CodeBreakAA,
}
pub type GeneticCodeTable = Vec<GeneticCode>;
#[derive(Clone, Serialize, Deserialize, PartialEq, Debug)]
pub struct ImpFeat {
pub key: String,
pub loc: Option<String>,
pub descr: Option<String>,
}
#[derive(Clone, Serialize, Deserialize, PartialEq, Debug, Default)]
pub struct GbQual {
pub qual: String,
pub val: String,
}
impl XmlNode for GbQual {
fn start_bytes() -> BytesStart<'static> {
BytesStart::new("Gb-qual")
}
fn from_reader(reader: &mut Reader<&[u8]>) -> Option<Self> where Self: Sized {
let mut qual = Self::default();
let qual_tag = BytesStart::new("Gb-qual_qual");
let val_tag = BytesStart::new("Gb-qual_val");
let forbidden = UnexpectedTags(&[]);
loop {
match reader.read_event().unwrap() {
Event::Start(e) => {
let name = e.name();
if name == qual_tag.name() {
qual.qual = read_string(reader).unwrap();
} else if name == val_tag.name() {
qual.val = read_string(reader).unwrap();
} else {
forbidden.check(&name);
}
}
Event::End(e) => {
if Self::is_end(&e) {
return qual.into()
}
}
_ => ()
}
}
}
}
impl XmlVecNode for GbQual {}
#[derive(Clone, Serialize_repr, Deserialize_repr, PartialEq, Debug)]
#[repr(u8)]
pub enum CloneRefPlacementMethod {
EndSeq,
InsertAlignment,
STS,
Fish,
Fingerprint,
EndSeqInsertAlignment,
External = 253,
Curated = 254,
Other = 255,
}
#[derive(Clone, Serialize, Deserialize, PartialEq, Debug)]
#[serde(rename_all = "kebab-case")]
pub struct CloneRef {
pub name: String,
pub library: Option<String>,
pub concordant: bool, pub unique: bool, pub placement_method: Option<CloneRefPlacementMethod>,
pub clone_seq: Option<CloneSeqSet>,
}
pub type CloneSeqSet = Vec<CloneSeq>;
#[derive(Clone, Serialize_repr, Deserialize_repr, PartialEq, Debug)]
#[repr(u8)]
pub enum CloneSeqType {
Insert,
End,
Other = 255,
}
#[derive(Clone, Serialize_repr, Deserialize_repr, PartialEq, Debug)]
#[repr(u8)]
pub enum CloneSeqConfidence {
Multiple,
Na,
NoHitRep,
NoHitNoRep,
OtherChrm,
Unique,
Virtual,
MultipleRep,
MultipleNoRep,
NoHit,
Other = 255,
}
#[derive(Clone, Serialize_repr, Deserialize_repr, PartialEq, Debug)]
#[repr(u8)]
pub enum CloneSeqSupport {
Prototype,
Supporting,
SupportsOther,
NonSupporting,
}
#[derive(Clone, Serialize, Deserialize, PartialEq, Debug)]
#[serde(rename_all = "kebab-case")]
pub struct CloneSeq {
#[serde(rename = "type")]
pub r#type: CloneSeqType,
pub confidence: Option<CloneSeqConfidence>,
pub location: SeqLoc,
pub seq: Option<SeqLoc>,
pub align_id: Option<DbTag>,
pub support: Option<CloneSeqSupport>,
}
bitflags! {
#[derive(Clone, Serialize, Deserialize, PartialEq, Debug)]
pub struct VariantResourceLink: u8 {
const Preserved = 1;
const Provisional = 2;
const Has3D = 4;
const SubmitterLinkout = 8;
const Clinical = 16;
const GenotypeKit = 32;
}}
bitflags! {
#[derive(Clone, Serialize, Deserialize, PartialEq, Debug)]
pub struct VariantGeneLocation: u32 {
const InGene = 1;
const NearGene5 = 2;
const NearGene3 = 4;
const Intron = 8;
const Donor = 16;
const Acceptor = 32;
const UTR5 = 64;
const UTR3 = 128;
const InStartCodon = 256;
const InStopCodon = 512;
const Intergenic = 1024;
const ConservedNoncoding = 2048;
}
}
bitflags! {
#[derive(Clone, Serialize, Deserialize, PartialEq, Debug)]
pub struct VariantEffect: u16 {
const NoChange = 0;
const Synonymous = 1;
const Nonsense = 2;
const Missense = 4;
const Frameshift = 8;
const UpRegulator = 16;
const DownRegulator = 32;
const Methylation = 64;
const StopGain = 128;
const StopLoss = 256;
}
}
bitflags! {
#[derive(Clone, Serialize, Deserialize, PartialEq, Debug)]
pub struct VariantMapping: u8 {
const HasOtherSnp = 1;
const HasAssemblyConflict = 2;
const IsAssemblySpecific = 4;
}
}
#[derive(Clone, Serialize_repr, Deserialize_repr, PartialEq, Debug)]
#[repr(u8)]
pub enum VariantMapWeight {
IsUniquelyPlaced = 1,
PlacedTwiceOnSameChrom = 2,
PlacedTypeOnDiffChrom = 3,
ManyPlacements = 10,
}
bitflags! {
#[derive(Clone, Serialize, Deserialize, PartialEq, Debug)]
pub struct FrequencyBasedValidation: u8 {
const IsMutation = 1;
const Above5pctAll = 2;
const Above5pct1plus = 4;
const Validated = 8;
const Above1pctAll = 16;
const Above1pct1plus = 32;
}
}
#[derive(Clone, Serialize_repr, Deserialize_repr, PartialEq, Debug)]
#[repr(u8)]
pub enum VariantGenotype {
InHaplotypeSet,
HasGenotypes,
}
bitflags! {
#[derive(Clone, Serialize, Deserialize, PartialEq, Debug)]
pub struct VariantQualityCheck: u8 {
const ContigAlleleMissing = 1;
const WithdrawnBySubmitter = 2;
const NonOverlappingAlleles = 4;
const StrainSpecific = 8;
const GenotypeConflict = 16;
}
}
#[derive(Clone, Serialize_repr, Deserialize_repr, PartialEq, Debug)]
#[repr(u8)]
pub enum VariantConfidence {
Unknown,
LikelyArtifact,
Other = 255,
}
bitflags! {
#[derive(Clone, Serialize, Deserialize, PartialEq, Debug)]
pub struct VariantAlleleOrigin: u32 {
const Unknown = 0;
const Germline = 1;
const Somatic = 2;
const Inherited = 4;
const Paternal = 8;
const Maternal = 16;
const DeNovo = 32;
const Biparental = 64;
const Uniparental = 128;
const NotTested = 256;
const TestedInconclusive = 512;
const NotReported = 1024;
const Other = 1073741824;
}
}
#[derive(Clone, Serialize_repr, Deserialize_repr, PartialEq, Debug)]
#[repr(u8)]
pub enum VariantAlleleState {
Unknown,
Homosygous,
Heterozygous,
Hemizygous,
Nullizygous,
Other = 255,
}
#[derive(Clone, Serialize, Deserialize, PartialEq, Debug)]
#[serde(rename_all = "kebab-case")]
pub struct VariantProperties {
pub version: u64,
pub resource_link: Option<VariantResourceLink>,
pub gene_location: Option<VariantGeneLocation>,
pub effect: Option<VariantEffect>,
pub mapping: Option<VariantMapping>,
pub map_weight: Option<VariantMapWeight>,
pub frequency_based_validation: Option<FrequencyBasedValidation>,
pub genotype: Option<VariantGenotype>,
pub quality_check: Option<VariantQualityCheck>,
pub confidence: VariantConfidence,
pub other_validation: Option<bool>,
pub allele_origin: Option<VariantAlleleOrigin>,
pub allele_state: Option<VariantAlleleState>,
pub allele_frequency: Option<f64>,
pub is_ancestral_allele: Option<bool>,
}
#[derive(Clone, Serialize_repr, Deserialize_repr, PartialEq, Debug)]
#[repr(u8)]
pub enum PhenotypeClinicalSignificance {
Unknown,
Untested,
NonPathogenic,
ProbableNonPathogenic,
ProbablePathogenic,
Pathogenic,
DrugResponse,
Histocompatibility,
Other = 255,
}
#[derive(Clone, Serialize, Deserialize, PartialEq, Debug)]
#[serde(rename_all = "kebab-case")]
pub struct Phenotype {
pub source: Option<String>,
pub term: Option<String>,
pub xref: Option<Vec<DbTag>>,
pub clinical_significance: Option<PhenotypeClinicalSignificance>,
}
bitflags! {
#[derive(Clone, Serialize, Deserialize, PartialEq, Debug)]
pub struct PopulationDataFlags: u8 {
const IsDefaultPopulation = 1;
const IsMinorAllele = 2;
const IsRareAllele = 4;
}
}
#[derive(Clone, Serialize, Deserialize, PartialEq, Debug)]
#[serde(rename_all = "kebab-case")]
pub struct PopulationData {
pub population: String,
pub genotype_frequency: Option<f64>,
pub chromosomes_tested: Option<u64>,
pub sample_ids: Option<Vec<ObjectId>>,
pub allele_frequency: Option<f64>,
pub flags: Option<PopulationDataFlags>,
}
#[derive(Clone, Serialize, Deserialize, PartialEq, Debug)]
pub struct ExtLoc {
pub id: ObjectId,
pub location: SeqLoc,
}
#[derive(Clone, Serialize_repr, Deserialize_repr, PartialEq, Debug)]
#[repr(u8)]
pub enum VariantRefMethod {
Unknown,
BacAcgh,
Computational,
Curated,
DigitalArray,
ExpressionArray,
Fish,
FlankingSequence,
Maph,
McdAnalysis,
Mlpa,
OeaAssembly,
OligoAcgh,
PairedEnd,
Pcr,
Qpcr,
ReadDepth,
Roma,
RtPcr,
Sage,
SequenceAlignment,
Sequencing,
SnpArray,
Southern,
Western,
OpticalMapping,
Other = 255,
}
#[derive(Clone, Serialize_repr, Deserialize_repr, PartialEq, Debug)]
#[repr(u8)]
pub enum VariationRefDataSetType {
Unknown,
Compound,
Products,
Haplotype,
Genotype,
Mosaic,
Individual,
Population,
Alleles,
Package,
Other = 255,
}
#[derive(Clone, Serialize, Deserialize, PartialEq, Debug)]
pub struct VariationRefDataSet {
#[serde(rename = "type")]
pub r#type: VariationRefDataSetType,
pub variations: Vec<VariationRef>,
pub name: Option<String>,
}
#[derive(Clone, Serialize, Deserialize, PartialEq, Debug)]
#[serde(rename_all = "kebab-case")]
pub enum VariationRefData {
Unknown,
Note(String),
UniparentalDisomy,
Instance(VariationInst),
Set(Vec<VariationRefDataSet>),
Variations(Vec<VariationRef>),
Complex,
}
#[derive(Clone, Serialize, Deserialize, PartialEq, Debug)]
#[serde(rename_all = "kebab-case")]
pub struct VariationFrameshift {
pub phase: Option<i64>,
pub x_length: Option<i64>,
}
#[derive(Clone, Serialize, Deserialize, PartialEq, Debug)]
#[serde(rename_all = "kebab-case")]
pub struct VariationLossOfHeterozygosity {
pub reference: Option<String>,
pub test: Option<String>,
}
#[derive(Clone, Serialize, Deserialize, PartialEq, Debug)]
#[serde(rename_all = "kebab-case")]
pub enum VariationConsequence {
Unknown,
Splicing,
Note(String),
Variation(VariationRef),
Frameshift(VariationFrameshift),
LossOfHeterozygosity(VariationLossOfHeterozygosity),
}
#[derive(Clone, Serialize, Deserialize, PartialEq, Debug)]
#[serde(rename_all = "kebab-case")]
pub struct SomaticOriginCondition {
pub description: Option<String>,
pub object_id: Option<Vec<DbTag>>,
}
#[derive(Clone, Serialize, Deserialize, PartialEq, Debug)]
pub struct VariationSomaticOrigin {
pub source: Option<SubSource>,
pub condition: Option<SomaticOriginCondition>,
}
#[derive(Clone, Serialize, Deserialize, PartialEq, Debug)]
#[serde(rename_all = "kebab-case")]
pub struct VariationRef {
pub id: Option<DbTag>,
pub parent_id: Option<DbTag>,
pub sample_id: Option<ObjectId>,
pub other_ids: Option<Vec<DbTag>>,
pub name: Option<String>,
pub synonyms: Option<Vec<String>>,
pub description: Option<String>,
pub phenotype: Option<Vec<Phenotype>>,
pub method: Option<Vec<VariantRefMethod>>,
pub variant_prop: Option<VariantProperties>,
pub data: VariationRefData,
pub consequence: Option<Vec<VariationConsequence>>,
pub somatic_origin: Option<Vec<VariationSomaticOrigin>>,
}
#[derive(Clone, Serialize, Deserialize, PartialEq, Debug)]
#[serde(rename_all = "kebab-case")]
pub enum DeltaSeq {
Literal(SeqLiteral),
Loc(SeqLoc),
This,
}
#[derive(Clone, Serialize_repr, Deserialize_repr, PartialEq, Debug, Default)]
#[repr(u8)]
pub enum DeltaAction {
#[default]
Morph,
Offset,
DelAt,
InsBefore,
}
#[derive(Clone, Serialize, Deserialize, PartialEq, Debug)]
#[serde(rename_all = "kebab-case")]
pub struct DeltaItem {
pub seq: Option<DeltaSeq>,
pub multiplier: Option<i64>, pub multiplier_fuzz: Option<IntFuzz>,
pub action: DeltaAction,
}
#[derive(Clone, Serialize_repr, Deserialize_repr, PartialEq, Debug)]
#[repr(u8)]
pub enum VariationInstType {
Unknown,
Identity,
Inv,
Snv,
Mnp,
#[serde(rename = "delins")]
DelIns,
Del,
Ins,
Microsatellite,
Transposon,
Cnv,
DirectCopy,
RevDirectCopy,
InvertedCopy,
EvertedCopy,
Translocation,
ProtMissense,
ProtNonsense,
ProtNeutral,
ProtSilent,
ProtOther,
Other = 255,
}
#[derive(Clone, Serialize_repr, Deserialize_repr, PartialEq, Debug)]
#[repr(u8)]
pub enum VariationInstObservation {
Asserted = 1,
Reference = 2,
Variant = 4,
}
#[derive(Clone, Serialize, Deserialize, PartialEq, Debug)]
pub struct VariationInst {
#[serde(rename = "type")]
pub r#type: VariationInstType,
pub delta: Vec<DeltaItem>,
pub observation: Option<VariationInstObservation>,
}
#[derive(Clone, Serialize, Deserialize, PartialEq, Debug)]
#[serde(rename_all = "lowercase")]
pub enum RSiteRef {
Str(String),
DB(DbTag),
}
#[allow(non_camel_case_types)]
#[derive(Clone, Serialize_repr, Deserialize_repr, PartialEq, Debug)]
#[repr(u8)]
pub enum RnaRefType {
Unknown,
PreMsg,
mRNA,
tRNA,
rRNA,
snRNA,
scRNA,
snoRNA,
ncRNA,
tmRNA,
MiscRNA,
Other = 255,
}
#[allow(non_camel_case_types)]
#[derive(Clone, Serialize, Deserialize, PartialEq, Debug)]
#[serde(rename_all = "lowercase")]
pub enum RnaRefExt {
Name(String),
tRNA(TRnaExt),
Gen(RnaGen),
}
#[derive(Clone, Serialize, Deserialize, PartialEq, Debug)]
pub struct RnaRef {
#[serde(rename = "type")]
pub r#type: RnaRefType,
pub pseudo: Option<bool>,
pub ext: Option<RnaRefExt>,
}
#[derive(Clone, Serialize, Deserialize, PartialEq, Debug)]
#[serde(rename_all = "lowercase")]
pub enum TRnaExtAa {
IUPACAa(u64),
NCBIEaa(u64),
NCBI8aa(u64),
NCBIStdAa(u64),
}
#[derive(Clone, Serialize, Deserialize, PartialEq, Debug)]
pub struct TRnaExt {
pub aa: TRnaExtAa,
pub codon: Option<Vec<u64>>,
pub anticodon: Option<SeqLoc>,
}
#[derive(Clone, Serialize, Deserialize, PartialEq, Debug)]
pub struct RnaGen {
pub class: Option<String>,
pub product: Option<String>,
pub quals: Option<RnaQualSet>,
}
#[derive(Clone, Serialize, Deserialize, PartialEq, Debug)]
pub struct RnaQual {
pub qual: String,
pub val: String,
}
pub type RnaQualSet = Vec<RnaQual>;
#[derive(Clone, Serialize, Deserialize, PartialEq, Debug, Default)]
#[serde(rename_all = "kebab-case")]
pub struct GeneRef {
pub locus: Option<String>,
pub allele: Option<String>,
pub desc: Option<String>,
pub maploc: Option<String>,
pub pseudo: bool,
pub db: Option<Vec<DbTag>>,
pub syn: Option<Vec<String>>,
pub locus_tag: Option<String>,
pub formal_name: Option<GeneNomenclature>,
}
impl XmlNode for GeneRef {
fn start_bytes() -> BytesStart<'static> {
BytesStart::new("Gene-ref")
}
fn from_reader(reader: &mut Reader<&[u8]>) -> Option<Self> where Self: Sized {
let mut gene = Self::default();
let locus_tag = BytesStart::new("Gene-ref_locus");
let allele_tag = BytesStart::new("Gene-ref_allele");
let desc_tag = BytesStart::new("Gene-ref_desc");
let maploc_tag = BytesStart::new("Gene-ref_maploc");
let pseudo_tag = BytesStart::new("Gene-ref_pseudo");
let db_tag = BytesStart::new("Gene-ref_db");
let syn_tag = BytesStart::new("Gene-ref_syn");
let locus_tag_tag = BytesStart::new("Gene-ref_locus-tag");
let form_name_tag = BytesStart::new("Gene-ref_formal-name");
let forbidden = [
pseudo_tag,
syn_tag,
form_name_tag,
];
let forbidden = UnexpectedTags(&forbidden);
loop {
match reader.read_event().unwrap() {
Event::Start(e) => {
let name = e.name();
if name == locus_tag.name() {
gene.locus = read_string(reader);
} else if name == allele_tag.name() {
gene.allele = read_string(reader);
} else if name == desc_tag.name() {
gene.desc = read_string(reader);
} else if name == maploc_tag.name() {
gene.maploc = read_string(reader);
} else if name == db_tag.name() {
gene.db = Some(read_vec_node(reader, db_tag.to_end()));
} else if name == locus_tag_tag.name() {
gene.locus_tag = read_string(reader);
} else if name != Self::start_bytes().name() {
forbidden.check(&name);
}
}
Event::End(e) => {
if Self::is_end(&e) {
return gene.into()
}
}
_ => ()
}
}
}
}
#[derive(Clone, Serialize_repr, Deserialize_repr, PartialEq, Debug)]
#[repr(u8)]
pub enum GeneNomenclatureStatus {
Unknown,
Official,
Interim,
}
#[derive(Clone, Serialize, Deserialize, PartialEq, Debug)]
pub struct GeneNomenclature {
pub status: GeneNomenclatureStatus,
pub symbol: Option<String>,
pub name: Option<String>,
pub source: Option<DbTag>,
}
#[derive(Clone, Serialize, Deserialize, PartialEq, Debug, Default)]
pub struct OrgRef {
pub taxname: Option<String>,
pub common: Option<String>,
pub r#mod: Option<Vec<String>>,
pub db: Option<Vec<DbTag>>,
pub syn: Option<Vec<String>>,
pub orgname: Option<OrgName>,
}
impl XmlNode for OrgRef {
fn start_bytes() -> BytesStart<'static> {
BytesStart::new("Org-ref")
}
fn from_reader(reader: &mut Reader<&[u8]>) -> Option<Self> {
let mut org_ref = OrgRef::default();
let taxname_element = BytesStart::new("Org-ref_taxname");
let db_element = BytesStart::new("Org-ref_db");
let orgname_element = BytesStart::new("Org-ref_orgname");
let forbidden = UnexpectedTags(&[]);
loop {
match reader.read_event().unwrap() {
Event::Start(e) => {
let name = e.name();
if name == taxname_element.name() {
org_ref.taxname = read_string(reader);
} else if name == orgname_element.name() {
org_ref.orgname = read_node(reader);
} else if name == db_element.name() {
org_ref.db = Some(read_vec_node(reader, db_element.to_end()))
} else if name != Self::start_bytes().name() {
forbidden.check(&name);
}
}
Event::End(e) => {
if Self::is_end(&e) {
return org_ref.into();
}
}
_ => (),
}
}
}
}
#[derive(Clone, Serialize, Deserialize, PartialEq, Debug)]
#[serde(rename_all = "lowercase")]
pub enum OrgNameChoice {
Binomial(BinomialOrgName),
Virus(String),
Hybrid(MultiOrgName),
NamedHybrid(BinomialOrgName),
Partial(PartialOrgName),
}
impl XmlNode for OrgNameChoice {
fn start_bytes() -> BytesStart<'static> {
BytesStart::new("OrgName_name")
}
fn from_reader(reader: &mut Reader<&[u8]>) -> Option<Self>
where
Self: Sized,
{
let binomial_element = BytesStart::new("OrgName_name_binomial");
loop {
match reader.read_event().unwrap() {
Event::Start(e) => {
let name = e.name();
if name == binomial_element.name() {
return Self::Binomial(read_node(reader).unwrap()).into();
}
}
Event::End(e) => {
if Self::is_end(&e) {
return None;
}
}
_ => (),
}
}
}
}
#[derive(Clone, Serialize, Deserialize, PartialEq, Debug, Default)]
pub struct OrgName {
pub name: Option<OrgNameChoice>,
pub attrib: Option<String>,
#[serde(rename = "mod")]
pub r#mod: Option<Vec<OrgMod>>,
pub lineage: Option<String>,
pub gcode: Option<u64>,
pub mgcode: Option<u64>,
pub div: Option<String>,
pub pgcode: Option<u64>,
}
impl XmlNode for OrgName {
fn start_bytes() -> BytesStart<'static> {
BytesStart::new("OrgName")
}
fn from_reader(reader: &mut Reader<&[u8]>) -> Option<Self>
where
Self: Sized,
{
let mut org_name = OrgName::default();
let name_element = BytesStart::new("OrgName_name");
let attrib_element = BytesStart::new("OrgName_attrib");
let mod_element = BytesStart::new("OrgName_mod");
let lineage_element = BytesStart::new("OrgName_lineage");
let gcode_element = BytesStart::new("OrgName_gcode");
let div_element = BytesStart::new("OrgName_div");
let forbidden = UnexpectedTags(&[]);
loop {
match reader.read_event().unwrap() {
Event::Start(e) => {
let name = e.name();
if name == div_element.name() {
org_name.div = read_string(reader);
} else if name == attrib_element.name() {
org_name.attrib = read_string(reader);
} else if name == lineage_element.name() {
org_name.lineage = read_string(reader);
} else if name == gcode_element.name() {
org_name.gcode = read_int(reader);
} else if name == name_element.name() {
org_name.name = read_node(reader);
} else if name == mod_element.name() {
org_name.r#mod = Some(read_vec_node(reader, mod_element.to_end()));
} else if name != Self::start_bytes().name() {
forbidden.check(&name);
}
}
Event::End(e) => {
if Self::is_end(&e) {
return org_name.into();
}
}
_ => (),
}
}
}
}
enum_from_primitive! {
#[derive(Clone, Serialize_repr, Deserialize_repr, PartialEq, Debug)]
#[repr(u8)]
pub enum OrgModSubType {
Strain = 2,
SubStrain,
Type,
SubType,
Variety,
Serotype,
Serogroup,
Serovar,
Cultivar,
Pathovar,
Chemovar,
Biovar,
Biotype,
Group,
SubGroup,
Isolate,
Common,
Acronym,
Dosage,
NatHost,
SubSpecies,
SpecimenVoucher,
Authority,
Forma,
FormaSpecialis,
Ecotype,
Synonym,
Anamorph,
Breed,
GbAcronym,
GbAnamorph,
GbSynonym,
CultureCollection,
BioMaterial,
MetagenomeSource,
TypeMaterial,
Nomenclature,
OldLineage = 253,
OldName = 254,
Other = 255,
}
}
impl Default for OrgModSubType {
fn default() -> Self {
Self::Other
}
}
impl XmlNode for OrgModSubType {
fn start_bytes() -> BytesStart<'static> {
BytesStart::new("OrgMod_subtype")
}
fn from_reader(reader: &mut Reader<&[u8]>) -> Option<Self>
where
Self: Sized,
{
Self::from_u8(read_int(reader).unwrap())
}
}
#[derive(Clone, Serialize, Deserialize, PartialEq, Debug, Default)]
pub struct OrgMod {
pub subtype: OrgModSubType,
pub subname: String,
pub attrib: Option<String>,
}
impl XmlNode for OrgMod {
fn start_bytes() -> BytesStart<'static> {
BytesStart::new("OrgMod")
}
fn from_reader(reader: &mut Reader<&[u8]>) -> Option<Self>
where
Self: Sized,
{
let mut r#mod = Self::default();
let subtype_element = BytesStart::new("OrgMod_subtype");
let subname_element = BytesStart::new("OrgMod_subname");
let attrib_element = BytesStart::new("OrgMod_attrib");
let forbidden = UnexpectedTags(&[]);
loop {
match reader.read_event().unwrap() {
Event::Start(e) => {
let name = e.name();
if name == subtype_element.name() {
r#mod.subtype = read_node(reader).unwrap();
} else if name == subname_element.name() {
r#mod.subname = read_string(reader).unwrap();
} else if name == attrib_element.name() {
r#mod.attrib = read_string(reader);
} else if name != Self::start_bytes().name() {
forbidden.check(&name);
}
}
Event::End(e) => {
if Self::is_end(&e) {
return r#mod.into();
}
}
_ => (),
}
}
}
}
impl XmlVecNode for OrgMod {}
#[derive(Clone, Serialize, Deserialize, PartialEq, Debug, Default)]
pub struct BinomialOrgName {
pub genus: String,
pub species: Option<String>,
pub subspecies: Option<String>,
}
impl XmlNode for BinomialOrgName {
fn start_bytes() -> BytesStart<'static> {
BytesStart::new("BinomialOrgName")
}
fn from_reader(reader: &mut Reader<&[u8]>) -> Option<Self>
where
Self: Sized,
{
let mut binomial = BinomialOrgName::default();
let genus_element = BytesStart::new("BinomialOrgName_genus");
let species_element = BytesStart::new("BinomialOrgName_species");
let subspecies_element = BytesStart::new("BinomialOrgName_subspecies");
let forbidden = UnexpectedTags(&[]);
loop {
match reader.read_event().unwrap() {
Event::Start(e) => {
let name = e.name();
if name == genus_element.name() {
binomial.genus = read_string(reader).unwrap();
} else if name == species_element.name() {
binomial.species = read_string(reader);
} else if name == subspecies_element.name() {
binomial.subspecies = read_string(reader);
} else if name != Self::start_bytes().name() {
forbidden.check(&name);
}
}
Event::End(e) => {
if Self::is_end(&e) {
return binomial.into();
}
}
_ => (),
}
}
}
}
pub type MultiOrgName = Vec<OrgName>;
pub type PartialOrgName = Vec<TaxElement>;
#[derive(Clone, Serialize_repr, Deserialize_repr, PartialEq, Debug)]
#[repr(u8)]
pub enum TaxElementFixedLevel {
Other,
Family,
Order,
Class,
}
#[derive(Clone, Serialize, Deserialize, PartialEq, Debug)]
#[serde(rename_all = "kebab-case")]
pub struct TaxElement {
pub fixed_level: TaxElementFixedLevel,
pub level: Option<String>,
pub name: String,
}
enum_from_primitive! {
#[derive(Clone, Serialize_repr, Deserialize_repr, PartialEq, Debug, Default)]
#[repr(u8)]
pub enum BioSourceGenome {
#[default]
Unknown,
Genomic,
Chloroplast,
Chromoplast,
Kinetoplast,
Mitochondrion,
Plastid,
Macronuclear,
Extrachrom,
Plasmid,
Transposon,
InsertionSeq,
Cyanelle,
Proviral,
Virion,
Nucleomorph,
Apicoplast,
Leucoplast,
Proplastid,
EndogenousVirus,
Hydrogenosome,
Chromosome,
PlasmidInMitochondrion,
PlasmidInPlastid,
}
}
impl XmlNode for BioSourceGenome {
fn start_bytes() -> BytesStart<'static> {
BytesStart::new("BioSource_genome")
}
fn from_reader(reader: &mut Reader<&[u8]>) -> Option<Self> {
Self::from_u8(read_int(reader).unwrap())
}
}
#[derive(Clone, Serialize_repr, Deserialize_repr, PartialEq, Debug, Default)]
#[repr(u8)]
pub enum BioSourceOrigin {
#[default]
Unknown,
Natural,
NatMut,
Mut,
Artificial,
Synthetic,
Other = 255,
}
#[derive(Clone, Serialize, Deserialize, PartialEq, Debug, Default)]
#[serde(rename_all = "kebab-case")]
pub struct BioSource {
pub genome: BioSourceGenome,
pub origin: BioSourceOrigin,
pub org: OrgRef,
pub subtype: Option<Vec<SubSource>>,
pub is_focus: Option<()>,
pub pcr_primers: Option<PCRReationSet>,
}
impl XmlNode for BioSource {
fn start_bytes() -> BytesStart<'static> {
BytesStart::new("BioSource")
}
fn from_reader(reader: &mut Reader<&[u8]>) -> Option<Self> {
let mut source = Self::default();
let genome_element = BytesStart::new("BioSource_genome");
let _origin_element = BytesStart::new("BioSource_origin");
let org_element = BytesStart::new("BioSource_org");
let subtype_element = BytesStart::new("BioSource_subtype");
let forbidden = UnexpectedTags(&[]);
loop {
match reader.read_event().unwrap() {
Event::Start(e) => {
let name = e.name();
if name == genome_element.name() {
source.genome = read_node(reader).unwrap();
} else if name == org_element.name() {
source.org = read_node(reader).unwrap();
} else if name == subtype_element.name() {
source.subtype = Some(read_vec_node(reader, subtype_element.to_end()))
} else if name != Self::start_bytes().name() {
forbidden.check(&name);
}
}
Event::End(e) => {
if e.name() == Self::start_bytes().to_end().name() {
return source.into();
}
}
_ => (),
}
}
}
}
pub type PCRReationSet = Vec<PCRReaction>;
#[derive(Clone, Serialize, Deserialize, PartialEq, Debug)]
pub struct PCRReaction {
pub forward: Option<PCRPrimerSet>,
pub reverse: Option<PCRPrimerSet>,
}
pub type PCRPrimerSet = Vec<PCRPrimer>;
#[derive(Clone, Serialize, Deserialize, PartialEq, Debug)]
pub struct PCRPrimer {
pub seq: Option<PCRPrimerSeq>,
pub name: Option<PCRPrimerName>,
}
pub type PCRPrimerSeq = String;
pub type PCRPrimerName = String;
enum_from_primitive! {
#[derive(Clone, Serialize_repr, Deserialize_repr, PartialEq, Debug)]
#[repr(u8)]
pub enum SubSourceSubType {
Chromosome = 1,
Map,
Clone,
Subclone,
Haplotype,
Genotype,
Sex,
CellLine,
CellType,
TissueType,
CloneLib,
DevStage,
Frequency,
Germline,
Rearranged,
LabHost,
PopVariant,
TissueLib,
PlasmidName,
TransposonName,
InsertionSeqName,
PlastidName,
Country,
Segment,
EndogenousVirusName,
Transgenic,
EnvironmentalSample,
IsolationSource,
LatLon,
CollectionDate,
CollectedBy,
IdentifiedBy,
FwdPrimerSeq,
RevPrimerSeq,
FwdPrimerName,
RevPrimerName,
Metagenomic,
MatingType,
LinkageGroup,
Haplogroup,
WholeReplicon,
Phenotype,
Altitude,
Other = 255,
}
}
impl Default for SubSourceSubType {
fn default() -> Self {
Self::Other
}
}
impl XmlNode for SubSourceSubType {
fn start_bytes() -> BytesStart<'static> {
BytesStart::new("SubSource_subtype")
}
fn from_reader(reader: &mut Reader<&[u8]>) -> Option<Self> {
Self::from_u8(read_int(reader).unwrap())
}
}
#[derive(Clone, Serialize, Deserialize, PartialEq, Debug, Default)]
pub struct SubSource {
pub subtype: SubSourceSubType,
pub name: String,
pub attrib: Option<String>,
}
impl XmlNode for SubSource {
fn start_bytes() -> BytesStart<'static> {
BytesStart::new("SubSource")
}
fn from_reader(reader: &mut Reader<&[u8]>) -> Option<Self> {
let mut source = Self::default();
let subtype_element = BytesStart::new("SubSource_subtype");
let name_element = BytesStart::new("SubSource_name");
let attrib_element = BytesStart::new("SubSource_attrib");
let forbidden = UnexpectedTags(&[]);
loop {
match reader.read_event().unwrap() {
Event::Start(e) => {
let qname = e.name();
if qname == subtype_element.name() {
source.subtype = read_node(reader).unwrap();
} else if qname == name_element.name() {
source.name = read_string(reader).unwrap();
} else if qname == attrib_element.name() {
source.attrib = read_string(reader);
} else if qname != Self::start_bytes().name() {
forbidden.check(&qname);
}
}
Event::End(e) => {
if e.name() == Self::start_bytes().to_end().name() {
return source.into();
}
}
_ => (),
}
}
}
}
impl XmlVecNode for SubSource {}
#[derive(Clone, Serialize_repr, Deserialize_repr, PartialEq, Debug, Default)]
#[repr(u8)]
pub enum ProtRefProcessingStatus {
#[default]
NotSet,
PreProtein,
Mature,
SignalPeptide,
TransitPeptide,
ProPeptide,
}
#[derive(Clone, Serialize, Deserialize, PartialEq, Debug, Default)]
#[serde(rename_all = "kebab-case")]
pub struct ProtRef {
pub name: Option<Vec<String>>,
pub desc: Option<String>,
pub ec: Option<Vec<String>>,
pub activity: Option<Vec<String>>,
pub db: Option<Vec<DbTag>>,
pub processed: ProtRefProcessingStatus,
}
impl XmlNode for ProtRef {
fn start_bytes() -> BytesStart<'static> {
BytesStart::new("Prot-ref")
}
fn from_reader(reader: &mut Reader<&[u8]>) -> Option<Self> where Self: Sized {
let mut prot = Self::default();
let name_tag = BytesStart::new("Prot-ref_name");
let desc_tag = BytesStart::new("Prot-ref_desc");
let ec_tag = BytesStart::new("Prot-ref_ec");
let activity_tag = BytesStart::new("Prot-ref_activity");
let db_tag = BytesStart::new("Prot-ref_db");
let processed_tag = BytesStart::new("Prot-ref_processed");
let forbidden = [processed_tag];
let forbidden = UnexpectedTags(&forbidden);
loop {
match reader.read_event().unwrap() {
Event::Start(e) => {
let name = e.name();
if name == name_tag.name() {
prot.name = read_vec_str_unchecked(reader, &name_tag.to_end()).into();
} else if name == desc_tag.name() {
prot.desc = read_string(reader);
} else if name == ec_tag.name() {
prot.ec = read_vec_str_unchecked(reader, &ec_tag.to_end()).into();
} else if name == activity_tag.name() {
prot.activity = read_vec_str_unchecked(reader, &activity_tag.to_end()).into();
} else if name == db_tag.name() {
prot.db = read_vec_node(reader, db_tag.to_end()).into();
} else if name != Self::start_bytes().name() {
forbidden.check(&name);
}
}
Event::End(e) => {
if Self::is_end(&e) {
return prot.into()
}
}
_ => {}
}
}
}
}
#[derive(Clone, Serialize_repr, Deserialize_repr, PartialEq, Debug)]
#[repr(u8)]
pub enum TxSystem {
Unknown,
Pol1,
Pol2,
Pol3,
Bacterial,
Viral,
Rna,
Organelle,
Other = 255,
}
#[derive(Clone, Serialize_repr, Deserialize_repr, PartialEq, Debug)]
#[repr(u8)]
pub enum InitType {
Unknown,
Single,
Multiple,
Region,
}
#[derive(Clone, Serialize, Deserialize, PartialEq, Debug)]
#[serde(rename_all = "kebab-case")]
pub struct TxInit {
pub name: String,
pub syn: Option<Vec<String>>,
pub gene: Option<Vec<GeneRef>>,
pub protein: Option<Vec<ProtRef>>,
pub rna: Option<Vec<String>>,
pub expression: Option<String>,
pub txsystem: TxSystem,
pub txdescr: Option<String>,
pub txorg: Option<OrgRef>,
pub mapping_precise: bool,
pub location_accurate: bool,
pub inittype: InitType,
pub evidence: Option<Vec<TxEvidence>>,
}
#[derive(Clone, Serialize_repr, Deserialize_repr, PartialEq, Debug)]
#[repr(u8)]
pub enum TxEvidenceExpCode {
Unknown,
RnaSeq,
RnaSize,
NpMap,
NpSize,
PeSeq,
CDnaSeq,
PeMap,
PeSize,
PseudoSeq,
RevPeMap,
Other = 255,
}
#[derive(Clone, Serialize_repr, Deserialize_repr, PartialEq, Debug, Default)]
#[repr(u8)]
pub enum TxEvidenceExpressionSystem {
Unknown,
#[default]
Physiological,
InVitro,
Oocyte,
Transfection,
Transgenic,
Other = 255,
}
#[derive(Clone, Serialize, Deserialize, PartialEq, Debug)]
#[serde(rename_all = "kebab-case")]
pub struct TxEvidence {
pub exp_code: TxEvidenceExpCode,
pub expression_system: TxEvidenceExpressionSystem,
pub low_prec_data: bool, pub from_homolog: bool, }