use of de.ipbhalle.metfraglib.precursor.TopDownBitArrayPrecursor in project MetFragRelaunched by ipb-halle.
the class SimulateSpectrumHDX method generateDeuteratedSpectrumNegative.
/**
* @param candidate
* @return
* @throws AtomTypeNotKnownFromInputListException
* @throws Exception
*/
public static double[][] generateDeuteratedSpectrumNegative(ICandidate candidate, int method) throws AtomTypeNotKnownFromInputListException, Exception {
int numberPositions = searchForDeuteriumExchangeablePositions((TopDownBitArrayPrecursor) candidate.getPrecursorMolecule()).length;
HDTopDownBitArrayPrecursor preHDX = new HDTopDownBitArrayPrecursor(candidate.getImplicitHydrogenAtomContainer(), (byte) numberPositions);
preHDX.preprocessPrecursor();
MatchList matchList = candidate.getMatchList();
double[][] spectrumHDX = null;
if (method == 3)
spectrumHDX = new double[matchList.getNumberElements() * 2][2];
else
spectrumHDX = new double[matchList.getNumberElements()][2];
for (int i = 0; i < matchList.getNumberElements(); i++) {
IFragment frag = matchList.getElement(i).getBestMatchedFragment();
IPeak peak = matchList.getElement(i).getMatchedPeak();
int[] setAtoms = ((DefaultBitArrayFragment) frag).getAtomsFastBitArray().getSetIndeces();
int numberDeuteriums = 0;
for (int k = 0; k < setAtoms.length; k++) {
numberDeuteriums += preHDX.getNumberDeuteriumsConnectedToAtomIndex(0, setAtoms[k]);
}
spectrumHDX[i][1] = peak.getAbsoluteIntensity();
// [M-D]-
if (method == 1) {
spectrumHDX[i][0] = peak.getMass() - (numberDeuteriums) * Constants.HYDROGEN_MASS + (numberDeuteriums) * Constants.getMonoisotopicMassOfAtom("D");
spectrumHDX[i][0] += Constants.HYDROGEN_MASS - Constants.getMonoisotopicMassOfAtom("D");
} else // [M]-
if (method == 2) {
spectrumHDX[i][0] = peak.getMass() - (numberDeuteriums) * Constants.HYDROGEN_MASS + (numberDeuteriums) * Constants.getMonoisotopicMassOfAtom("D");
// nothing to do
} else // [M]- [M-D]-
if (method == 3) {
spectrumHDX[i * 2][0] = peak.getMass() - (numberDeuteriums) * Constants.HYDROGEN_MASS + (numberDeuteriums) * Constants.getMonoisotopicMassOfAtom("D");
spectrumHDX[(i * 2) + 1][0] = peak.getMass() - (numberDeuteriums) * Constants.HYDROGEN_MASS + (numberDeuteriums) * Constants.getMonoisotopicMassOfAtom("D");
spectrumHDX[(i * 2) + 1][0] += Constants.HYDROGEN_MASS - Constants.getMonoisotopicMassOfAtom("D");
} else // predict based on deuteriums
if (method == 4) {
spectrumHDX[i][0] = peak.getMass() - (numberDeuteriums) * Constants.HYDROGEN_MASS + (numberDeuteriums) * Constants.getMonoisotopicMassOfAtom("D");
if (numberDeuteriums != 0)
spectrumHDX[i][0] += Constants.HYDROGEN_MASS - Constants.getMonoisotopicMassOfAtom("D");
} else // predict based on adduct
if (method == 5) {
byte adductTypeIndex = ((DefaultFragmentToPeakMatch) matchList.getElement(i)).getBestMatchedFragmentAdductTypeIndex();
spectrumHDX[i][0] = peak.getMass() - (numberDeuteriums) * Constants.HYDROGEN_MASS + (numberDeuteriums) * Constants.getMonoisotopicMassOfAtom("D");
if (adductTypeIndex == 1)
spectrumHDX[i][0] += Constants.getMonoisotopicMassOfAtom("D") - Constants.HYDROGEN_MASS;
}
}
return spectrumHDX;
}
use of de.ipbhalle.metfraglib.precursor.TopDownBitArrayPrecursor in project MetFragRelaunched by ipb-halle.
the class TopDownPrecursorCandidate method initialisePrecursorCandidate.
@Override
public void initialisePrecursorCandidate() throws AtomTypeNotKnownFromInputListException, Exception {
this.precursorStructure = new TopDownBitArrayPrecursor(this.getImplicitHydrogenAtomContainer());
this.precursorStructure.preprocessPrecursor();
}
use of de.ipbhalle.metfraglib.precursor.TopDownBitArrayPrecursor in project MetFragRelaunched by ipb-halle.
the class SimulateSpectrumHDX method generateDeuteratedSpectrumPositive.
/**
* @param candidate
* @return
* @throws AtomTypeNotKnownFromInputListException
* @throws Exception
*/
public static double[][] generateDeuteratedSpectrumPositive(ICandidate candidate, int method) throws AtomTypeNotKnownFromInputListException, Exception {
int numberPositions = searchForDeuteriumExchangeablePositions((TopDownBitArrayPrecursor) candidate.getPrecursorMolecule()).length;
HDTopDownBitArrayPrecursor preHDX = new HDTopDownBitArrayPrecursor(candidate.getImplicitHydrogenAtomContainer(), (byte) numberPositions);
preHDX.preprocessPrecursor();
MatchList matchList = candidate.getMatchList();
double[][] spectrumHDX = null;
if (method == 3)
spectrumHDX = new double[matchList.getNumberElements() * 2][2];
else
spectrumHDX = new double[matchList.getNumberElements()][2];
for (int i = 0; i < matchList.getNumberElements(); i++) {
IFragment frag = matchList.getElement(i).getBestMatchedFragment();
IPeak peak = matchList.getElement(i).getMatchedPeak();
int[] setAtoms = ((DefaultBitArrayFragment) frag).getAtomsFastBitArray().getSetIndeces();
int numberDeuteriums = 0;
for (int k = 0; k < setAtoms.length; k++) {
numberDeuteriums += preHDX.getNumberDeuteriumsConnectedToAtomIndex(0, setAtoms[k]);
}
if (method != 3) {
spectrumHDX[i][1] = peak.getAbsoluteIntensity();
} else {
spectrumHDX[i * 2][1] = peak.getAbsoluteIntensity();
spectrumHDX[(i * 2) + 1][1] = peak.getAbsoluteIntensity();
}
// [M+D]+
if (method == 1) {
spectrumHDX[i][0] = peak.getMass() - (numberDeuteriums) * Constants.HYDROGEN_MASS + (numberDeuteriums) * Constants.getMonoisotopicMassOfAtom("D");
spectrumHDX[i][0] += Constants.getMonoisotopicMassOfAtom("D") - Constants.HYDROGEN_MASS;
} else // [M]+
if (method == 2) {
spectrumHDX[i][0] = peak.getMass() - (numberDeuteriums) * Constants.HYDROGEN_MASS + (numberDeuteriums) * Constants.getMonoisotopicMassOfAtom("D");
// nothing to do
} else // [M]+ [M+D]+
if (method == 3) {
spectrumHDX[i * 2][0] = peak.getMass() - (numberDeuteriums) * Constants.HYDROGEN_MASS + (numberDeuteriums) * Constants.getMonoisotopicMassOfAtom("D");
spectrumHDX[(i * 2) + 1][0] = peak.getMass() - (numberDeuteriums) * Constants.HYDROGEN_MASS + (numberDeuteriums) * Constants.getMonoisotopicMassOfAtom("D");
spectrumHDX[(i * 2) + 1][0] += Constants.getMonoisotopicMassOfAtom("D") - Constants.HYDROGEN_MASS;
} else // predict based on in silico added deuteriums
if (method == 4) {
spectrumHDX[i][0] = peak.getMass() - (numberDeuteriums) * Constants.HYDROGEN_MASS + (numberDeuteriums) * Constants.getMonoisotopicMassOfAtom("D");
if (numberDeuteriums != 0)
spectrumHDX[i][0] += Constants.getMonoisotopicMassOfAtom("D") - Constants.HYDROGEN_MASS;
} else // predict based on adduct
if (method == 5) {
byte adductTypeIndex = ((DefaultFragmentToPeakMatch) matchList.getElement(i)).getBestMatchedFragmentAdductTypeIndex();
spectrumHDX[i][0] = peak.getMass() - (numberDeuteriums) * Constants.HYDROGEN_MASS + (numberDeuteriums) * Constants.getMonoisotopicMassOfAtom("D");
if (adductTypeIndex == 2)
spectrumHDX[i][0] += Constants.getMonoisotopicMassOfAtom("D") - Constants.HYDROGEN_MASS;
}
if (method != 3) {
spectrumHDX[i][0] = MathTools.round(spectrumHDX[i][0]);
} else {
spectrumHDX[i * 2][0] = MathTools.round(spectrumHDX[i * 2][0]);
spectrumHDX[(i * 2) + 1][0] = MathTools.round(spectrumHDX[(i * 2) + 1][0]);
}
}
return spectrumHDX;
}
Aggregations