Skip to content

Commit

Permalink
fix: wrong proton equivalence count when it is multiple assigned
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelwenk committed Oct 22, 2021
1 parent 5bc8f02 commit c10fb31
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/utilities/build/setAttachmentsAndProtonEquivalences.ts
Expand Up @@ -29,6 +29,12 @@ export function setAttachmentsAndProtonEquivalences(
}
}
}
// set previously set equivalences of protons to 0
for (const correlation of correlations) {
if (correlation.atomType === 'H') {
correlation.equivalence = 0;
}
}
// reset previously set proton equivalences and set new ones
// check heavy atoms with an unambiguous protons count
for (const correlation of correlations) {
Expand All @@ -49,10 +55,16 @@ export function setAttachmentsAndProtonEquivalences(
(equivalence * equivalences) / correlation.attachment.H.length;

for (const attachedProtonIndex of correlation.attachment.H) {
correlations[attachedProtonIndex].equivalence = sharedEquivalences;
correlations[attachedProtonIndex].equivalence += sharedEquivalences;
}
}
}
// set unchanged equivalence of protons back to 1
for (const correlation of correlations) {
if (correlation.atomType === 'H' && correlation.equivalence === 0) {
correlation.equivalence = 1;
}
}

return correlations;
}

0 comments on commit c10fb31

Please sign in to comment.