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
use std::io::BufRead;
use std::str::FromStr;
use quick_xml::Reader;
use quick_xml::events::BytesStart;
use crate::error::Error;
use crate::parser::FromXml;
use crate::parser::utils::get_evidences;
#[derive(Debug, Default, Clone)]
pub struct SubcellularLocation {
pub locations: Vec<String>,
pub topologies: Vec<String>,
pub orientations: Vec<String>,
}
impl FromXml for SubcellularLocation {
fn from_xml<B: BufRead>(
event: &BytesStart,
reader: &mut Reader<B>,
buffer: &mut Vec<u8>
) -> Result<Self, Error> {
debug_assert_eq!(event.local_name(), b"subcellularLocation");
let mut subloc = SubcellularLocation::default();
parse_inner!{event, reader, buffer,
b"location" => {
subloc.locations.push(reader.read_text(b"location", buffer)?);
},
b"topology" => {
subloc.topologies.push(reader.read_text(b"topology", buffer)?);
},
b"orientation" => {
subloc.orientations.push(reader.read_text(b"orientation", buffer)?);
}
}
if subloc.locations.is_empty() {
return Err(Error::MissingElement("location", "SubcellularLocation"));
}
Ok(subloc)
}
}