Skip to content

total_protein_count means different things in peptinfo and the functional endpoints #103

Description

@bmesuere

🤖 peptinfo and the four functional endpoints (pept2ec, pept2go, pept2interpro, pept2funct) both return a field called total_protein_count, but they compute two different numbers.

peptinfo returns the number of matched proteins:

// api/src/controllers/api/peptinfo.rs
let total_protein_count = item.proteins.len();
// let total_protein_count = *fa.counts.get("all").unwrap_or(&0);

The other four return fa.counts["all"], which calculate_fa defines as the number of distinct proteins carrying at least one EC/GO/IPR annotation — not the number of matches:

// api/src/controllers/api/pept2funct.rs (same in pept2ec, pept2go, pept2interpro)
let total_protein_count = *fa.counts.get("all").unwrap_or(&0);

Live, for MPILGLK:

endpoint total_protein_count
pept2funct 509
peptinfo 573
pept2prot (number of entries returned) 573

peptinfo was changed to proteins.len() in 1605311 ("Fixed peptinfo total_protein_count was sometimes zero") because counts["all"] drops to 0 when none of the matched proteins are annotated. That fix was never propagated to the other four endpoints, which still have both that zero case and the undercount.

Assuming proteins.len() is the intended meaning everywhere, the fix is to apply the same change to pept2ec, pept2go, pept2interpro and pept2funct (and drop the commented-out line in peptinfo). If instead the annotated-protein count is wanted for the functional endpoints, it should get a distinct field name, since callers currently cannot tell the two apart.

Worth deciding before the API docs describe the field — the docs currently give it peptinfo's definition on all five pages (unipept/unipept#TBD).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions