wiki:DetermineGlycanInfo

Tutorial for Determining Glycan Feature Info

This page contains source code for determining glycan m/z, charge, sum of exchanges and losses

/**
 * Calculates dGlycanMz, dSumCharge, dSumExchanges, dSumLosses for the specified Glycan object based
 * on the adducts, exchanges and loss/gain.
 * 
 * @param glycan - a Glycan object
 * @param _analyteSettings - current AnalyteSettings object
 * @param lAdductsToAnalyze - List<List<IonSettings>> for adducts
 * @param lAdductsToAnalyzeCounts - List<List<Integer>> ion counts for adducts 
 * @param lExchangesToAnalyze - List<List<IonSettings>> for ion exchanges
 * @param lExchangesToAnalyzeCounts - List<List<Integer>> ion counts for ion exchanges
 * @param lNeutralLossesToAnalyze - List<List<IonSettings>> for neutral loss/gain
 * @param lNeutralLossesToAnalyzeCounts - List<List<Integer>> ion counts for neutral loss/gain
 * @return double[] - array containing {dGlycanMz, dSumCharge, dSumExchanges, dSumLosses};
 */
public static double[] getGlycanMzAndCharge( Glycan glycan, AnalyteSettings _analyteSettings, 
		List<IonSettings> lAdductsToAnalyze, List<Integer> lAdductsToAnalyzeCounts, 
		List<IonSettings> lExchangesToAnalyze, List<Integer> lExchangesToAnalyzeCounts,
		List<MoleculeSettings> lNeutralLossesToAnalyze, List<Integer> lNeutralLossesToAnalyzeCounts ) {
	double dMass = 0.0;
	try {
		dMass = glycan.computeMass();
	} catch( Exception e ) {
		dMass = glycan.computeMass();
		logger.error(e.getMessage(), e);
	}
	// add ion exchange mass 
	double dSumExchanges = 0d;
	if( lExchangesToAnalyze != null ) {
		for( int i = 0; i < lExchangesToAnalyze.size(); i++ ) {
			IonSettings ionExchange = lExchangesToAnalyze.get(i);
			int iCnt = lExchangesToAnalyzeCounts.get(i);
			double dMassChange = GlycanStructureAnnotation.getIonExchange(ionExchange, iCnt);
			dMass +=  dMassChange;
			dSumExchanges += (double) iCnt;
		}
	}
	// add any neutral losses
	double dSumLosses = 0d;
	if( lNeutralLossesToAnalyze != null ) {
		for( int i = 0; i < lNeutralLossesToAnalyze.size(); i++ ) {
			MoleculeSettings neutralLoss = lNeutralLossesToAnalyze.get(i);
			int iCnt = lNeutralLossesToAnalyzeCounts.get(i);
			double dMassChange = GlycanStructureAnnotation.getNeutralLoss(neutralLoss, iCnt);
			dMass +=  dMassChange;
			dSumLosses += (double) iCnt;
		}
	}

	// some up charges and masses of adducts
	double dSumCharge = 0d;
	double dSumMass = 0d;
	for( int i = 0; i < lAdductsToAnalyze.size(); i++ ) {
		IonSettings adduct = lAdductsToAnalyze.get(i);
		int iCnt = lAdductsToAnalyzeCounts.get(i);
		double z = GlycanStructureAnnotation.getChargeFromAdducts(iCnt,adduct);
		dSumCharge+=z;
		dSumMass += ((double) iCnt * adduct.getMass());
	}
	double dGlycanMz = GlycanStructureAnnotation.getGlycanStructureMz(dMass,dSumCharge,dSumMass);

	return new double[] {dGlycanMz, dSumCharge, dSumExchanges, dSumLosses};
}
Last modified 2 years ago Last modified on 06/28/2018 06:00:29 PM