use crate::interact::Interactive;
use crate::interact::InteractiveMap;
use std::error::Error;
use std::fs::File;
use std::io::{BufRead, BufReader};
impl Interactive {
pub fn intercative(&self) -> Result<Vec<InteractiveMap>, Box<dyn Error>> {
let fileopen = self.interactive.clone();
let filereadopen = File::open(fileopen).expect("file not present");
let filread = BufReader::new(filereadopen);
let mut pathdatabase: Vec<InteractiveMap> = Vec::new();
for i in filread.lines() {
let line = i.expect("file not present");
let linesplit = line
.split("\t")
.map(|x| x.to_string())
.filter(|x| x != "")
.collect::<Vec<_>>();
pathdatabase.push(InteractiveMap {
sourcetaxonid: linesplit[0].clone(),
sourcetaxontds: linesplit[1].clone(),
sourcetaxonname: linesplit[2].clone(),
sourcetaxonpathnames: linesplit[4].clone(),
sourcetaxonpathids: linesplit[5].clone(),
sourcetaxonsubgenusid: linesplit[10].clone(),
sourcetaxongenusname: linesplit[11].clone(),
sourcetaxonfamilyid: linesplit[14].clone(),
sourcetaxonfamilyname: linesplit[13].clone(),
reststring: linesplit.clone().concat(),
})
}
Ok(pathdatabase)
}
}