Skip to content

Commit

Permalink
[FIX] Decoding ontology in PeptideIdentification df conversion (#5659)
Browse files Browse the repository at this point in the history
* fix tuple creation

* add pep evidence export

* update test

* add pep evidence concatenation test

* change dtype for pep evidences to U1000

* fix error while decoding ontology

* simple test without decode_ontology
  • Loading branch information
axelwalter committed Nov 18, 2021
1 parent 75dee2b commit 7ae58db
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
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

0 comments on commit 7ae58db

Please sign in to comment.