usadellab / prot-scriber

Assigns short human readable descriptions to biological sequences or gene families using references. For this, prot-scriber consumes sequence similarity search results in tabular format (Blast or Diamond).
GNU General Public License v3.0
5 stars 5 forks source link

When the `generate_human_readable_description` function is implemented, connect it with the existing code #8

Closed asishallab closed 2 years ago

asishallab commented 2 years ago

Once the function is implemented that generates human readable descriptions (HRDs) from an input vector of candidate descriptions according to this spec, the function needs to be connected with the already existing code.

In order to do this please implement the TODOs in the two respective annotate functions in the seq_family.rs and query.rs modules:

query.rs

    /// Generates and returns a human readable description (`String`) for this biological query
    /// sequence.
    ///
    /// # Arguments
    ///
    /// * `&self` - A mutable reference to self, this instance of Query
    pub fn annotate(&self) -> String {
        // TODO: Gather all self.hits description fields and pass them to
        // `generate_human_readable_description`.
        (*UNKNOWN_PROTEIN_DESCRIPTION).to_string()
    }

seq_family.rs

    /// Generates and returns a human readable description (`String`) for this set (family) of
    /// biological query sequences.
    ///
    /// # Arguments
    ///
    /// * `&self` - A mutable reference to self, this instance of SeqFamily
    /// * `queries: &HashMap<String, Query>` - A constant reference to the in memory database of
    /// `Query` instances. This is used to extract the `Hit.description`s from.
    pub fn annotate(&self, queries: &HashMap<String, Query>) -> String {
        let mut candidate_descriptions: Vec<String> = vec![];
        // Gather all candidate descriptions of all queries belonging to this sequence family. This
        // means collecting all queries' hit-descriptions:
        for qid in self.query_ids.iter() {
            for (_, hit) in &queries.get(qid).unwrap().hits {
                candidate_descriptions.push(hit.description.clone());
            }
        }
        // TODO: Invoke `generate_human_readable_description(candidate_descriptions, ...)`
        (*UNKNOWN_FAMILY_DESCRIPTION).to_string()
    }