1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
use super::{Attribute, Field};

#[derive(Debug, Default)]
pub struct AttributeRef<'a> {
    pub gene_id: Option<&'a [u8]>,
    pub gene_version: Option<&'a [u8]>,
    pub gene_name: Option<&'a [u8]>,
    pub transcript_id: Option<&'a [u8]>,
    pub transcript_version: Option<&'a [u8]>,
    pub transcript_name: Option<&'a [u8]>,
    pub transcript_biotype: Option<&'a [u8]>,
    pub protein_id: Option<&'a [u8]>,
    pub exon_number: Option<&'a [u8]>,
}
impl <'a> AttributeRef <'a> {
    pub fn to_owned(&self) -> Attribute {
        let gene_id = self.gene_id.map(|x| x.to_owned());
        let gene_version = self.gene_version.map(|x| x.to_owned());
        let gene_name = self.gene_name.map(|x| x.to_owned());
        let transcript_id = self.transcript_id.map(|x| x.to_owned());
        let transcript_version = self.transcript_version.map(|x| x.to_owned());
        let transcript_name = self.transcript_name.map(|x| x.to_owned());
        let transcript_biotype = self.transcript_biotype.map(|x| x.to_owned());
        let protein_id = self.protein_id.map(|x| x.to_owned());
        let exon_number = self.exon_number.map(|x| x.to_owned());
        Attribute {
            gene_id,
            gene_version,
            gene_name,
            transcript_id,
            transcript_version,
            transcript_name,
            transcript_biotype,
            protein_id,
            exon_number
        }
    }
    pub fn update_field(&mut self, field: Field, value: &'a [u8]) {
        match field {
            Field::GeneId=> {
                self.gene_id = Some(value);
            },
            Field::GeneVersion => {
                self.gene_version = Some(value);
            },
            Field::GeneName => {
                self.gene_name = Some(value);
            },
            Field::TranscriptId => {
                self.transcript_id = Some(value);
            },
            Field::TranscriptVersion => {
                self.transcript_version = Some(value);
            },
            Field::TranscriptName => {
                self.transcript_name = Some(value);
            },
            Field::TranscriptBiotype => {
                self.transcript_biotype = Some(value);
            },
            Field::ProteinId => {
                self.protein_id = Some(value);
            },
            Field::ExonNumber => {
                self.exon_number = Some(value);
            },
        }
    }
}