| 1 | = Tutorial for Determining Glycan Feature Info= |
| 2 | This page contains source code for determining glycan m/z, charge, sum of exchanges and losses |
| 3 | {{{ |
| 4 | /** |
| 5 | * Calculates dGlycanMz, dSumCharge, dSumExchanges, dSumLosses for the specified Glycan object based |
| 6 | * on the adducts, exchanges and loss/gain. |
| 7 | * |
| 8 | * @param glycan - a Glycan object |
| 9 | * @param _analyteSettings - current AnalyteSettings object |
| 10 | * @param lAdductsToAnalyze - List<List<IonSettings>> for adducts |
| 11 | * @param lAdductsToAnalyzeCounts - List<List<Integer>> ion counts for adducts |
| 12 | * @param lExchangesToAnalyze - List<List<IonSettings>> for ion exchanges |
| 13 | * @param lExchangesToAnalyzeCounts - List<List<Integer>> ion counts for ion exchanges |
| 14 | * @param lNeutralLossesToAnalyze - List<List<IonSettings>> for neutral loss/gain |
| 15 | * @param lNeutralLossesToAnalyzeCounts - List<List<Integer>> ion counts for neutral loss/gain |
| 16 | * @return double[] - array containing {dGlycanMz, dSumCharge, dSumExchanges, dSumLosses}; |
| 17 | */ |
| 18 | public static double[] getGlycanMzAndCharge( Glycan glycan, AnalyteSettings _analyteSettings, |
| 19 | List<IonSettings> lAdductsToAnalyze, List<Integer> lAdductsToAnalyzeCounts, |
| 20 | List<IonSettings> lExchangesToAnalyze, List<Integer> lExchangesToAnalyzeCounts, |
| 21 | List<MoleculeSettings> lNeutralLossesToAnalyze, List<Integer> lNeutralLossesToAnalyzeCounts ) { |
| 22 | double dMass = 0.0; |
| 23 | try { |
| 24 | dMass = glycan.computeMass(); |
| 25 | } catch( Exception e ) { |
| 26 | dMass = glycan.computeMass(); |
| 27 | logger.error(e.getMessage(), e); |
| 28 | } |
| 29 | // add ion exchange mass |
| 30 | double dSumExchanges = 0d; |
| 31 | if( lExchangesToAnalyze != null ) { |
| 32 | for( int i = 0; i < lExchangesToAnalyze.size(); i++ ) { |
| 33 | IonSettings ionExchange = lExchangesToAnalyze.get(i); |
| 34 | int iCnt = lExchangesToAnalyzeCounts.get(i); |
| 35 | double dMassChange = GlycanStructureAnnotation.getIonExchange(ionExchange, iCnt); |
| 36 | dMass += dMassChange; |
| 37 | dSumExchanges += (double) iCnt; |
| 38 | } |
| 39 | } |
| 40 | // add any neutral losses |
| 41 | double dSumLosses = 0d; |
| 42 | if( lNeutralLossesToAnalyze != null ) { |
| 43 | for( int i = 0; i < lNeutralLossesToAnalyze.size(); i++ ) { |
| 44 | MoleculeSettings neutralLoss = lNeutralLossesToAnalyze.get(i); |
| 45 | int iCnt = lNeutralLossesToAnalyzeCounts.get(i); |
| 46 | double dMassChange = GlycanStructureAnnotation.getNeutralLoss(neutralLoss, iCnt); |
| 47 | dMass += dMassChange; |
| 48 | dSumLosses += (double) iCnt; |
| 49 | } |
| 50 | } |
| 51 | |
| 52 | // some up charges and masses of adducts |
| 53 | double dSumCharge = 0d; |
| 54 | double dSumMass = 0d; |
| 55 | for( int i = 0; i < lAdductsToAnalyze.size(); i++ ) { |
| 56 | IonSettings adduct = lAdductsToAnalyze.get(i); |
| 57 | int iCnt = lAdductsToAnalyzeCounts.get(i); |
| 58 | double z = GlycanStructureAnnotation.getChargeFromAdducts(iCnt,adduct); |
| 59 | dSumCharge+=z; |
| 60 | dSumMass += ((double) iCnt * adduct.getMass()); |
| 61 | } |
| 62 | double dGlycanMz = GlycanStructureAnnotation.getGlycanStructureMz(dMass,dSumCharge,dSumMass); |
| 63 | |
| 64 | return new double[] {dGlycanMz, dSumCharge, dSumExchanges, dSumLosses}; |
| 65 | } |
| 66 | }}} |