🤖 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).
🤖
peptinfoand the four functional endpoints (pept2ec,pept2go,pept2interpro,pept2funct) both return a field calledtotal_protein_count, but they compute two different numbers.peptinforeturns the number of matched proteins:The other four return
fa.counts["all"], whichcalculate_fadefines as the number of distinct proteins carrying at least one EC/GO/IPR annotation — not the number of matches:Live, for
MPILGLK:total_protein_countpept2functpeptinfopept2prot(number of entries returned)peptinfowas changed toproteins.len()in 1605311 ("Fixed peptinfo total_protein_count was sometimes zero") becausecounts["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 topept2ec,pept2go,pept2interproandpept2funct(and drop the commented-out line inpeptinfo). 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).