You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
if (replacement.containsKey(formulaString.toUpperCase())) {
419
-
f = MolecularFormula.parse(replacement.get(formulaString.toUpperCase()));
411
+
++fpos;
412
+
// could be isotope count
413
+
if (formulaString.equals("i")) {
414
+
if (!isAdd)
415
+
thrownewIllegalArgumentException("Cannot subtract isotopes from precursor ion type.");
416
+
isotopes += number;
417
+
number = 1;
418
+
isAdd = true;
419
+
} elseif (formulaString.equals("M")) {
420
+
// we already checked multimere count above
421
+
if (!isAdd) thrownewIllegalArgumentException("Cannot subtract neutral formula.");
422
+
if (fpos>1) thrownewIllegalArgumentException("Neutral formula M should be specified first in adduct string");
423
+
isAdd=true; number=1;
420
424
} else {
421
-
f = MolecularFormula.parse(formulaString);
422
-
}
423
-
if (number != 1) {
424
-
f = f.multiply(number);
425
-
}
425
+
// should be a molecular formula
426
+
MolecularFormulaf;
427
+
if (replacement.containsKey(formulaString.toUpperCase())) {
428
+
f = MolecularFormula.parse(replacement.get(formulaString.toUpperCase())).multiply(number);;
429
+
} else {
430
+
f = MolecularFormula.parse(formulaString);
431
+
if (f.atomCount()==1) {
432
+
f=f.multiply(number);
433
+
} elseif (prefixNumber != 1) {
434
+
thrownewIllegalArgumentException("Do not support nested groups in formula string: '" + name + "'");
435
+
}
436
+
}
426
437
427
-
possibleNewIonTypes.add(f);
438
+
possibleNewIonTypes.add(f);
428
439
429
-
if (isAdd) {
430
-
adducts.add(f);
431
-
} else {
432
-
insourceFrags.add(f);
440
+
if (isAdd) {
441
+
adducts.add(f);
442
+
} else {
443
+
insourceFrags.add(f);
444
+
}
445
+
isAdd = true;
446
+
number = 1;
433
447
}
434
-
isAdd = true;
435
-
number = 1;
436
-
437
448
}
438
449
}
439
450
}
440
451
}
441
452
442
453
finalintcharge = (isAdd ? 1 : -1);
443
454
455
+
/*
456
+
Given an ion type [M + X + Y]+ we do not know which of X or Y is the adduct or the charge. This is because we distinguish between modifications that carry the charge and cannot be removed but only
457
+
swapped with another adduct (e.g. Na+, K+, H+...) and modifications that can easily fragment off (e.g. NH3). Probably, the cleanest way would be to write adduct formulas like this:
458
+
[M + X + Y+] but this is just not the convention. So we instead check if we find X or Y in our predefined list of ions.
0 commit comments