Package com.compomics.util.experiment.biology.ions

Examples of com.compomics.util.experiment.biology.ions.PeptideFragmentIon


                int sequenceLength = peptide.getSequence().length();
                boolean[] aaCoverage = new boolean[sequenceLength];
                for (IonMatch ionMatch : matches) {
                    Ion ion = ionMatch.ion;
                    if (ion instanceof PeptideFragmentIon) {
                        PeptideFragmentIon peptideFragmentIon = (PeptideFragmentIon) ion;
                        int number = peptideFragmentIon.getNumber();
                        aaCoverage[number - 1] = true;
                    }
                }
                double nIons = 0.0;
                for (boolean aa : aaCoverage) {
                    if (aa) {
                        nIons += 1;
                    }
                }
                coverage = 100 * nIons / sequenceLength;
                return coverage + "";
            case longest_amino_acid_sequence_annotated:
                peptide = peptideAssumption.getPeptide();
                matches = peptideSpectrumAnnotator.getSpectrumAnnotation(
                        annotationPreferences.getIonTypes(), annotationPreferences.getNeutralLosses(), annotationPreferences.getValidatedCharges(),
                        peptideAssumption.getIdentificationCharge().value,
                        (MSnSpectrum) SpectrumFactory.getInstance().getSpectrum(spectrumKey), peptide, 0, searchParameters.getFragmentIonAccuracy(), false, true);
                sequence = peptide.getSequence();
                sequenceLength = sequence.length();
                boolean[] coverageForward = new boolean[sequenceLength];
                boolean[] coverageRewind = new boolean[sequenceLength];
                for (IonMatch ionMatch : matches) {
                    Ion ion = ionMatch.ion;
                    if (ion instanceof PeptideFragmentIon) {
                        PeptideFragmentIon peptideFragmentIon = (PeptideFragmentIon) ion;
                        int number = peptideFragmentIon.getNumber();
                        if (peptideFragmentIon.getSubType() == PeptideFragmentIon.A_ION
                                || peptideFragmentIon.getSubType() == PeptideFragmentIon.B_ION
                                || peptideFragmentIon.getSubType() == PeptideFragmentIon.C_ION) {
                            coverageForward[number - 1] = true;
                        } else {
                            coverageRewind[number - 1] = true;
                        }
                    }
                }
                aaCoverage = new boolean[sequenceLength];
                boolean previous = true;
                for (int aaIndex = 0; aaIndex < sequenceLength; aaIndex++) {
                    boolean current = coverageForward[aaIndex];
                    if (current && previous) {
                        aaCoverage[aaIndex] = true;
                    }
                    previous = current;
                }
                previous = true;
                for (int aaIndex = 0; aaIndex < sequenceLength; aaIndex++) {
                    boolean current = coverageRewind[aaIndex];
                    if (current && previous) {
                        aaCoverage[sequenceLength - aaIndex - 1] = true;
                    }
                    previous = current;
                }
                StringBuilder currentTag = new StringBuilder();
                String longestTag = new String();
                for (int aaIndex = 0; aaIndex < sequenceLength; aaIndex++) {
                    if (aaCoverage[aaIndex]) {
                        currentTag.append(sequence.charAt(aaIndex));
                    } else {
                        if (currentTag.length() > longestTag.length()) {
                            longestTag = currentTag.toString();
                        }
                        currentTag = new StringBuilder();
                    }
                }
                if (currentTag.length() > longestTag.length()) {
                    longestTag = currentTag.toString();
                }
                return longestTag;
            case longest_amino_acid_sequence_annotated_single_serie:
                peptide = peptideAssumption.getPeptide();
                matches = peptideSpectrumAnnotator.getSpectrumAnnotation(
                        annotationPreferences.getIonTypes(), annotationPreferences.getNeutralLosses(), annotationPreferences.getValidatedCharges(),
                        peptideAssumption.getIdentificationCharge().value,
                        (MSnSpectrum) SpectrumFactory.getInstance().getSpectrum(spectrumKey), peptide, 0, searchParameters.getFragmentIonAccuracy(), false, true);
                sequence = peptide.getSequence();
                sequenceLength = sequence.length();
                HashMap<Integer, boolean[]> ionCoverage = new HashMap<Integer, boolean[]>(6);
                ionCoverage.put(PeptideFragmentIon.A_ION, new boolean[sequenceLength]);
                ionCoverage.put(PeptideFragmentIon.B_ION, new boolean[sequenceLength]);
                ionCoverage.put(PeptideFragmentIon.C_ION, new boolean[sequenceLength]);
                ionCoverage.put(PeptideFragmentIon.X_ION, new boolean[sequenceLength]);
                ionCoverage.put(PeptideFragmentIon.Y_ION, new boolean[sequenceLength]);
                ionCoverage.put(PeptideFragmentIon.Z_ION, new boolean[sequenceLength]);
                for (IonMatch ionMatch : matches) {
                    if (ionMatch.charge.value == 1) {
                        Ion ion = ionMatch.ion;
                        if (ion instanceof PeptideFragmentIon) {
                            PeptideFragmentIon peptideFragmentIon = (PeptideFragmentIon) ion;
                            int number = peptideFragmentIon.getNumber();
                            if (peptideFragmentIon.getSubType() == PeptideFragmentIon.A_ION && peptideFragmentIon.getNeutralLosses().isEmpty()) {
                                ionCoverage.get(PeptideFragmentIon.A_ION)[number - 1] = true;
                            } else if (peptideFragmentIon.getSubType() == PeptideFragmentIon.B_ION && peptideFragmentIon.getNeutralLosses().isEmpty()) {
                                ionCoverage.get(PeptideFragmentIon.B_ION)[number - 1] = true;
                            } else if (peptideFragmentIon.getSubType() == PeptideFragmentIon.C_ION && peptideFragmentIon.getNeutralLosses().isEmpty()) {
                                ionCoverage.get(PeptideFragmentIon.C_ION)[number - 1] = true;
                            } else if (peptideFragmentIon.getSubType() == PeptideFragmentIon.X_ION && peptideFragmentIon.getNeutralLosses().isEmpty()) {
                                ionCoverage.get(PeptideFragmentIon.X_ION)[number - 1] = true;
                            } else if (peptideFragmentIon.getSubType() == PeptideFragmentIon.Y_ION && peptideFragmentIon.getNeutralLosses().isEmpty()) {
                                ionCoverage.get(PeptideFragmentIon.Y_ION)[number - 1] = true;
                            } else if (peptideFragmentIon.getSubType() == PeptideFragmentIon.Z_ION && peptideFragmentIon.getNeutralLosses().isEmpty()) {
                                ionCoverage.get(PeptideFragmentIon.Z_ION)[number - 1] = true;
                            }
                        }
                    }
                }
                longestTag = new String();
                currentTag = new StringBuilder();
                previous = true;
                for (int aaIndex = 0; aaIndex < sequenceLength; aaIndex++) {
                    boolean current = ionCoverage.get(PeptideFragmentIon.A_ION)[aaIndex];
                    if (current && previous) {
                        currentTag.append(sequence.charAt(aaIndex));
                    } else {
                        if (currentTag.length() > longestTag.length()) {
                            longestTag = currentTag.toString();
                        }
                        currentTag = new StringBuilder();
                    }
                    previous = current;
                }
                if (currentTag.length() > longestTag.length()) {
                    longestTag = currentTag.reverse().toString();
                }
                currentTag = new StringBuilder();
                previous = true;
                for (int aaIndex = 0; aaIndex < sequenceLength; aaIndex++) {
                    boolean current = ionCoverage.get(PeptideFragmentIon.B_ION)[aaIndex];
                    if (current && previous) {
                        currentTag.append(sequence.charAt(aaIndex));
                    } else {
                        if (currentTag.length() > longestTag.length()) {
                            longestTag = currentTag.toString();
                        }
                        currentTag = new StringBuilder();
                    }
                    previous = current;
                }
                if (currentTag.length() > longestTag.length()) {
                    longestTag = currentTag.reverse().toString();
                }
                currentTag = new StringBuilder();
                previous = true;
                for (int aaIndex = 0; aaIndex < sequenceLength; aaIndex++) {
                    boolean current = ionCoverage.get(PeptideFragmentIon.C_ION)[aaIndex];
                    if (current && previous) {
                        currentTag.append(sequence.charAt(aaIndex));
                    } else {
                        if (currentTag.length() > longestTag.length()) {
                            longestTag = currentTag.toString();
                        }
                        currentTag = new StringBuilder();
                    }
                    previous = current;
                }
                if (currentTag.length() > longestTag.length()) {
                    longestTag = currentTag.reverse().toString();
                }
                currentTag = new StringBuilder();
                previous = true;
                for (int aaIndex = 0; aaIndex < sequenceLength; aaIndex++) {
                    boolean current = ionCoverage.get(PeptideFragmentIon.X_ION)[aaIndex];
                    if (current && previous) {
                        currentTag.append(sequence.charAt(sequenceLength - aaIndex - 1));
                    } else {
                        if (currentTag.length() > longestTag.length()) {
                            longestTag = currentTag.reverse().toString();
                        }
                        currentTag = new StringBuilder();
                    }
                    previous = current;
                }
                if (currentTag.length() > longestTag.length()) {
                    longestTag = currentTag.reverse().toString();
                }
                currentTag = new StringBuilder();
                previous = true;
                for (int aaIndex = 0; aaIndex < sequenceLength; aaIndex++) {
                    boolean current = ionCoverage.get(PeptideFragmentIon.Y_ION)[aaIndex];
                    if (current && previous) {
                        currentTag.append(sequence.charAt(sequenceLength - aaIndex - 1));
                    } else {
                        if (currentTag.length() > longestTag.length()) {
                            longestTag = currentTag.reverse().toString();
                        }
                        currentTag = new StringBuilder();
                    }
                    previous = current;
                }
                if (currentTag.length() > longestTag.length()) {
                    longestTag = currentTag.reverse().toString();
                }
                currentTag = new StringBuilder();
                previous = true;
                for (int aaIndex = 0; aaIndex < sequenceLength; aaIndex++) {
                    boolean current = ionCoverage.get(PeptideFragmentIon.Z_ION)[aaIndex];
                    if (current && previous) {
                        currentTag.append(sequence.charAt(sequenceLength - aaIndex - 1));
                    } else {
                        if (currentTag.length() > longestTag.length()) {
                            longestTag = currentTag.reverse().toString();
                        }
                        currentTag = new StringBuilder();
                    }
                    previous = current;
                }
                if (currentTag.length() > longestTag.length()) {
                    longestTag = currentTag.reverse().toString();
                }

                return longestTag;
            case amino_acids_annotated:
                peptide = peptideAssumption.getPeptide();
                spectrum = SpectrumFactory.getInstance().getSpectrum(spectrumKey);
                matches = peptideSpectrumAnnotator.getSpectrumAnnotation(
                        annotationPreferences.getIonTypes(), annotationPreferences.getNeutralLosses(), annotationPreferences.getValidatedCharges(),
                        peptideAssumption.getIdentificationCharge().value,
                        (MSnSpectrum) spectrum, peptide, 0, searchParameters.getFragmentIonAccuracy(), false, true);
                sequence = peptide.getSequence();
                sequenceLength = sequence.length();
                coverageForward = new boolean[sequenceLength];
                coverageRewind = new boolean[sequenceLength];
                for (IonMatch ionMatch : matches) {
                    Ion ion = ionMatch.ion;
                    if (ion instanceof PeptideFragmentIon) {
                        PeptideFragmentIon peptideFragmentIon = (PeptideFragmentIon) ion;
                        int number = peptideFragmentIon.getNumber();
                        if (peptideFragmentIon.getSubType() == PeptideFragmentIon.A_ION
                                || peptideFragmentIon.getSubType() == PeptideFragmentIon.B_ION
                                || peptideFragmentIon.getSubType() == PeptideFragmentIon.C_ION) {
                            coverageForward[number - 1] = true;
                        } else {
                            coverageRewind[number - 1] = true;
                        }
                    }
View Full Code Here


            for (IonMatch ionMatch : annotations) {

                if (ionMatch.ion.getType() == Ion.IonType.PEPTIDE_FRAGMENT_ION) {

                    PeptideFragmentIon peptideFragmentIon = (PeptideFragmentIon) ionMatch.ion;

                    if (peptideFragmentIon.getNeutralLosses().isEmpty()) {

                        //Q1
                        Charge charge = bestAssumption.getIdentificationCharge();
                        double theoreticPrecMz = (peptide.getMass() + charge.value * ElementaryIon.proton.getTheoreticMass()) / charge.value;
                        writer.write(theoreticPrecMz + SEPARATOR);

                        //Q3
                        double theoreticFragMz = ionMatch.ion.getTheoreticMz(charge.value);
                        writer.write(theoreticFragMz + SEPARATOR);

                        // RT_detected
                        double rt = spectrum.getPrecursor().getRt();
                        writer.write(rt + SEPARATOR);

                        // isotope
                        writer.write("Light" + SEPARATOR);

                        // uniprot_id
                        writer.write(accession + SEPARATOR);

                        // relative intensity
                        double intensity = ionMatch.peak.intensity; //@TODO: normalize in some way?
                        writer.write(intensity + SEPARATOR);

                        // sequence
                        String sequence = peptide.getSequence();
                        writer.write(sequence + SEPARATOR);

                        // modified sequence
                        String modifiedSequence = "";
                        for (int aa = 0; aa < sequence.length(); aa++) {
                            modifiedSequence += sequence.charAt(aa);
                            for (ModificationMatch modificationMatch : peptide.getModificationMatches()) {
                                if (modificationMatch.getModificationSite() == aa + 1) {
                                    String ptmName = modificationMatch.getTheoreticPtm();
                                    PTM ptm = ptmFactory.getPTM(ptmName);
                                    CvTerm cvTerm = null;
                                    if (ptmToPrideMap != null) {
                                        try {
                                            cvTerm = ptmToPrideMap.getCVTerm(ptmName);
                                            if (cvTerm == null) {
                                                cvTerm = PtmToPrideMap.getDefaultCVTerm(ptmName);
                                            }
                                        } catch (Exception e) {
                                        }
                                    }
                                    if (cvTerm != null) {
                                        modifiedSequence += "[" + cvTerm.getName() + "]";
                                    } else {
                                        modifiedSequence += "[" + ptm.getShortName() + "]";
                                    }
                                }
                            }
                        }
                        writer.write(modifiedSequence + SEPARATOR);

                        // prec_z
                        writer.write(charge.value + SEPARATOR);

                        // protein name
                        writer.write(SequenceFactory.getInstance().getHeader(accession).getDescriptionProteinName() + SEPARATOR);

                        // fragment type
                        writer.write(peptideFragmentIon.getSubTypeAsString() + SEPARATOR);

                        // fragment z
                        writer.write(ionMatch.charge.value + SEPARATOR);

                        // fragment number
                        writer.write(peptideFragmentIon.getNumber() + SEPARATOR);

                        writer.newLine();
                    }
                }
            }
View Full Code Here

            }

            if (annotationPreferences.getFragmentIonTypes().contains(PeptideFragmentIon.A_ION)) {
                try {
                    getColumn("a" + modification).setCellRenderer(new JSparklinesBarChartTableCellRenderer(PlotOrientation.HORIZONTAL, tableContent.getMaxIntensity(),
                            SpectrumPanel.determineFragmentIonColor(new PeptideFragmentIon(PeptideFragmentIon.A_ION), false)));
                    ((JSparklinesBarChartTableCellRenderer) getColumn("a" + modification).getCellRenderer()).setMinimumChartValue(0);
                } catch (IllegalArgumentException e) {
                    // do nothing
                }
            }
            if (annotationPreferences.getFragmentIonTypes().contains(PeptideFragmentIon.B_ION)) {
                try {
                    getColumn("b" + modification).setCellRenderer(new JSparklinesBarChartTableCellRenderer(PlotOrientation.HORIZONTAL, tableContent.getMaxIntensity(),
                            SpectrumPanel.determineFragmentIonColor(new PeptideFragmentIon(PeptideFragmentIon.B_ION), false)));
                    ((JSparklinesBarChartTableCellRenderer) getColumn("b" + modification).getCellRenderer()).setMinimumChartValue(0);
                } catch (IllegalArgumentException e) {
                    // do nothing
                }
            }
            if (annotationPreferences.getFragmentIonTypes().contains(PeptideFragmentIon.C_ION)) {
                try {
                    getColumn("c" + modification).setCellRenderer(new JSparklinesBarChartTableCellRenderer(PlotOrientation.HORIZONTAL, tableContent.getMaxIntensity(),
                            SpectrumPanel.determineFragmentIonColor(new PeptideFragmentIon(PeptideFragmentIon.C_ION), false)));
                    ((JSparklinesBarChartTableCellRenderer) getColumn("c" + modification).getCellRenderer()).setMinimumChartValue(0);
                } catch (IllegalArgumentException e) {
                    // do nothing
                }
            }

            if (annotationPreferences.getFragmentIonTypes().contains(PeptideFragmentIon.X_ION)) {
                try {
                    getColumn("x" + modification).setCellRenderer(new JSparklinesBarChartTableCellRenderer(PlotOrientation.HORIZONTAL, tableContent.getMaxIntensity(),
                            SpectrumPanel.determineFragmentIonColor(new PeptideFragmentIon(PeptideFragmentIon.X_ION), false)));
                    ((JSparklinesBarChartTableCellRenderer) getColumn("x" + modification).getCellRenderer()).setMinimumChartValue(0);
                } catch (IllegalArgumentException e) {
                    // do nothing
                }
            }
            if (annotationPreferences.getFragmentIonTypes().contains(PeptideFragmentIon.Y_ION)) {
                try {
                    getColumn("y" + modification).setCellRenderer(new JSparklinesBarChartTableCellRenderer(PlotOrientation.HORIZONTAL, tableContent.getMaxIntensity(),
                            SpectrumPanel.determineFragmentIonColor(new PeptideFragmentIon(PeptideFragmentIon.Y_ION), false)));
                    ((JSparklinesBarChartTableCellRenderer) getColumn("y" + modification).getCellRenderer()).setMinimumChartValue(0);
                } catch (IllegalArgumentException e) {
                    // do nothing
                }
            }
            if (annotationPreferences.getFragmentIonTypes().contains(PeptideFragmentIon.Z_ION)) {
                try {
                    getColumn("z" + modification).setCellRenderer(new JSparklinesBarChartTableCellRenderer(PlotOrientation.HORIZONTAL, tableContent.getMaxIntensity(),
                            SpectrumPanel.determineFragmentIonColor(new PeptideFragmentIon(PeptideFragmentIon.Z_ION), false)));
                    ((JSparklinesBarChartTableCellRenderer) getColumn("z" + modification).getCellRenderer()).setMinimumChartValue(0);
                } catch (IllegalArgumentException e) {
                    // do nothing
                }
            }
View Full Code Here

TOP

Related Classes of com.compomics.util.experiment.biology.ions.PeptideFragmentIon

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.