Skip to content

Commit

Permalink
split the functional annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
tibvdm committed Aug 28, 2024
1 parent f15e3f8 commit 8067226
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 8 deletions.
8 changes: 6 additions & 2 deletions sa-index/src/peptide_search.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,19 @@ pub struct SearchResult {
pub struct ProteinInfo {
pub taxon: u32,
pub uniprot_accession: String,
pub functional_annotations: String
pub ec_numbers: String,
pub go_terms: String,
pub interpro_entries: String
}

impl From<&Protein> for ProteinInfo {
fn from(protein: &Protein) -> Self {
ProteinInfo {
taxon: protein.taxon_id,
uniprot_accession: protein.uniprot_id.clone(),
functional_annotations: protein.get_functional_annotations()
ec_numbers: protein.get_ec_numbers(),
go_terms: protein.get_go_terms(),
interpro_entries: protein.get_interpro_entries()
}
}
}
Expand Down
25 changes: 19 additions & 6 deletions sa-mappings/src/proteins.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ pub struct Protein {
pub taxon_id: u32,

/// The encoded functional annotations of the protein
pub functional_annotations: Vec<u8>
pub ec_numbers: Vec<u8>,
pub go_terms: Vec<u8>,

Check failure on line 26 in sa-mappings/src/proteins.rs

View workflow job for this annotation

GitHub Actions / Clippy + rustfmt

missing documentation for a struct field

Check warning on line 26 in sa-mappings/src/proteins.rs

View workflow job for this annotation

GitHub Actions / Check + test

missing documentation for a struct field

Check warning on line 26 in sa-mappings/src/proteins.rs

View workflow job for this annotation

GitHub Actions / Check + test

missing documentation for a struct field
pub interpro_entries: Vec<u8>

Check failure on line 27 in sa-mappings/src/proteins.rs

View workflow job for this annotation

GitHub Actions / Clippy + rustfmt

missing documentation for a struct field

Check warning on line 27 in sa-mappings/src/proteins.rs

View workflow job for this annotation

GitHub Actions / Check + test

missing documentation for a struct field

Check warning on line 27 in sa-mappings/src/proteins.rs

View workflow job for this annotation

GitHub Actions / Check + test

missing documentation for a struct field
}

/// A struct that represents a collection of proteins
Expand All @@ -35,9 +37,16 @@ pub struct Proteins {
}

impl Protein {
/// Returns the decoded functional annotations of the protein
pub fn get_functional_annotations(&self) -> String {
decode(&self.functional_annotations)
pub fn get_ec_numbers(&self) -> String {

Check failure on line 40 in sa-mappings/src/proteins.rs

View workflow job for this annotation

GitHub Actions / Clippy + rustfmt

missing documentation for a method

Check warning on line 40 in sa-mappings/src/proteins.rs

View workflow job for this annotation

GitHub Actions / Check + test

missing documentation for a method

Check warning on line 40 in sa-mappings/src/proteins.rs

View workflow job for this annotation

GitHub Actions / Check + test

missing documentation for a method
decode(&self.ec_numbers)
}

pub fn get_go_terms(&self) -> String {

Check failure on line 44 in sa-mappings/src/proteins.rs

View workflow job for this annotation

GitHub Actions / Clippy + rustfmt

missing documentation for a method

Check warning on line 44 in sa-mappings/src/proteins.rs

View workflow job for this annotation

GitHub Actions / Check + test

missing documentation for a method

Check warning on line 44 in sa-mappings/src/proteins.rs

View workflow job for this annotation

GitHub Actions / Check + test

missing documentation for a method
decode(&self.go_terms)
}

pub fn get_interpro_entries(&self) -> String {

Check failure on line 48 in sa-mappings/src/proteins.rs

View workflow job for this annotation

GitHub Actions / Clippy + rustfmt

missing documentation for a method

Check warning on line 48 in sa-mappings/src/proteins.rs

View workflow job for this annotation

GitHub Actions / Check + test

missing documentation for a method

Check warning on line 48 in sa-mappings/src/proteins.rs

View workflow job for this annotation

GitHub Actions / Check + test

missing documentation for a method
decode(&self.interpro_entries)
}
}

Expand Down Expand Up @@ -72,15 +81,19 @@ impl Proteins {
let uniprot_id = from_utf8(fields.next().unwrap())?;
let taxon_id = from_utf8(fields.next().unwrap())?.parse()?;
let sequence = from_utf8(fields.next().unwrap())?;
let functional_annotations: Vec<u8> = encode(from_utf8(fields.next().unwrap())?);
let ec_numbers: Vec<u8> = encode(from_utf8(fields.next().unwrap())?);
let go_terms: Vec<u8> = encode(from_utf8(fields.next().unwrap())?);
let interpro_entries: Vec<u8> = encode(from_utf8(fields.next().unwrap())?);

input_string.push_str(&sequence.to_uppercase());
input_string.push(SEPARATION_CHARACTER.into());

proteins.push(Protein {
uniprot_id: uniprot_id.to_string(),
taxon_id,
functional_annotations
ec_numbers,
go_terms,
interpro_entries
});
}

Expand Down

0 comments on commit 8067226

Please sign in to comment.