Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] Decoding ontology in PeptideIdentification df conversion #5659

Merged
merged 8 commits into from Nov 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 8 additions & 5 deletions src/pyOpenMS/pyopenms/dataframes.py
Expand Up @@ -288,11 +288,14 @@ def get_key(val):
return key
dmv = [default_missing_values[get_key(t)] for t in types]

decodedMVs = [m.decode("utf-8") for m in metavals] if decode_ontology else metavals
cv = ControlledVocabulary()
cv.loadFromOBO("psims", File.getOpenMSDataPath() + "/CV/psi-ms.obo")
clearMVs = [cv.getTerm(m).name if m.startswith("MS:") else m for m in decodedMVs]
#cols = ["id", "RT", "mz", "score", "charge"] + decodedMVs
decodedMVs = [m.decode("utf-8") for m in metavals]
if decode_ontology:
cv = ControlledVocabulary()
cv.loadFromOBO("psims", File.getOpenMSDataPath() + "/CV/psi-ms.obo")
clearMVs = [cv.getTerm(m).name if m.startswith("MS:") else m for m in decodedMVs]
else:
clearMVs = decodedMVs

clearcols = ["id", "RT", "mz", mainscorename, "charge", "protein_accession", "start", "end"] + clearMVs
coltypes = ['U100', 'f', 'f', 'f', 'i','U1000', 'U1000', 'U1000'] + types
dt = list(zip(clearcols, coltypes))
Expand Down
1 change: 1 addition & 0 deletions src/pyOpenMS/tests/unittests/test000.py
Expand Up @@ -2278,6 +2278,7 @@ def test_peptide_identifications_to_df():
peps.append(p1)

assert pyopenms.peptide_identifications_to_df(peps).shape == (2,10)
assert pyopenms.peptide_identifications_to_df(peps, decode_ontology=False).shape == (2,10)
assert pyopenms.peptide_identifications_to_df(peps)['protein_accession'][0] == 'sp|Accession1,sp|Accession2'
assert pyopenms.peptide_identifications_to_df(peps, export_unidentified=False).shape == (1,10)

Expand Down