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

Protein disulf #315

Merged
merged 3 commits into from
Feb 1, 2024
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -646,6 +646,31 @@ public void proteinMolFormulaTest() {
"Formula must be the same when protein sequence includes lowercase codes");
}

@Test
public void proteinMolFormulaDisulfidesTest() {
ProteinSubstance proteinSubstance = new ProteinSubstance();
Protein protein = new Protein();
Subunit subunit1= new Subunit();
protein.subunits = new ArrayList<>();
protein.subunits.add(subunit1);
subunit1.sequence =
"CMMC";

DisulfideLink disulfideLink = new DisulfideLink();
List<Site> sitesDisulfide = new ArrayList<>();
sitesDisulfide.add(new Site(1, 1));
sitesDisulfide.add(new Site(1, 4));
disulfideLink.setSites(sitesDisulfide);
protein.setDisulfideLinks(Collections.singletonList(disulfideLink));
proteinSubstance.setProtein(protein);

Set<String> unknownResidues = new HashSet<>();

MolecularWeightAndFormulaContribution contribution=ProteinUtils.generateProteinWeightAndFormula(substanceRepository,
proteinSubstance, unknownResidues);
assertEquals("C16H28N4O5S4", contribution.getFormula());
}

@Test
public void aparaginePeptideMolFormulaTest() {
ProteinSubstance proteinSubstance = new ProteinSubstance();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,8 @@ public static MolecularWeightAndFormulaContribution generateProteinWeightAndForm
log.trace(String.format("basic MW: %.2f; basic formula: %s; disulfideContribution: %.2f",
total, makeFormulaFromMap(formulaCounts), disulfideContribution));
total -= disulfideContribution;
int numberOfHydrogensToRemove = getNumberOfHydrogensToRemoveForDisulfides(ps.protein);
log.trace("numberOfHydrogensToRemove: {}", numberOfHydrogensToRemove);
Map<String, SingleThreadCounter> formulaMapWithContrib[] =new Map[1];
formulaMapWithContrib[0]=formulaCounts;
if (ps.hasModifications() && ps.modifications.structuralModifications.size() > 0) {
Expand Down Expand Up @@ -413,6 +415,10 @@ else if (contribution.getMw() > 0 || (contribution.getMwHigh() > 0 && contributi
log.debug("no mods to consider");
}

if( formulaMapWithContrib[0].containsKey("H")) {
log.trace("going to remove {} H atoms for disulfide bonds", numberOfHydrogensToRemove);
formulaMapWithContrib[0].get("H").decrement(numberOfHydrogensToRemove);
}
log.trace(String.format("final total: %.2f; highTotal: %.2f; lowTotal: %.2f; highLimitTotal: %.2f; lowLimitTotal: %.2f", total,
highTotal, lowTotal, highLimitTotal, lowLimitTotal));
result = new MolecularWeightAndFormulaContribution(total, ps.substanceClass.toString(), formulaMapWithContrib[0]);
Expand Down Expand Up @@ -738,6 +744,12 @@ public static double getDisulfideContribution(Protein protein) {
: 0.0d;
}

public static int getNumberOfHydrogensToRemoveForDisulfides(Protein protein) {
return (protein != null && protein.getDisulfideLinks() != null)
? 2 * protein.getDisulfideLinks().size()
: 0;
}

public static Map<String,SingleThreadCounter> subtractFormulas(Map<String,SingleThreadCounter> minuend, Map<String,SingleThreadCounter> subtrahend){
Map<String,SingleThreadCounter> difference = new HashMap<>();
minuend.keySet().forEach(s->{
Expand Down
Loading