本文整理汇总了Java中com.compomics.util.experiment.biology.Peptide类的典型用法代码示例。如果您正苦于以下问题:Java Peptide类的具体用法?Java Peptide怎么用?Java Peptide使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Peptide类属于com.compomics.util.experiment.biology包,在下文中一共展示了Peptide类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getScore
import com.compomics.util.experiment.biology.Peptide; //导入依赖的package包/类
/**
* Scores the match between the given peptide and spectrum using the
* intensity rank of the matched peaks. The score goes from the most intense
* peaks to the lowest and returns the intensity rank at which more than 1%
* of the total number of peaks is not annotated.
*
* @param peptide the peptide of interest
* @param spectrum the spectrum of interest
* @param annotationPreferences the general spectrum annotation preferences
* @param specificAnnotationPreferences the annotation preferences specific to this psm
* @param peptideSpectrumAnnotator the spectrum annotator to use
*
* @return the score of the match
*
* @throws java.lang.InterruptedException exception thrown if the thread is
* interrupted
*/
public double getScore(Peptide peptide, MSnSpectrum spectrum, AnnotationSettings annotationPreferences, SpecificAnnotationSettings specificAnnotationPreferences, PeptideSpectrumAnnotator peptideSpectrumAnnotator) throws InterruptedException {
double nMissedTolerance = 10 * ((double) spectrum.getNPeaks()) / 100;
HashMap<Double, ArrayList<Peak>> intensityMap = spectrum.getIntensityMap();
ArrayList<Double> intensities = new ArrayList<Double>(intensityMap.keySet());
Collections.sort(intensities, Collections.reverseOrder());
double rank = 0;
int missed = 0;
for (double intensity : intensities) {
for (Peak peak : intensityMap.get(intensity)) {
if (peptideSpectrumAnnotator.matchPeak(peptide, specificAnnotationPreferences, peak).isEmpty()) { //Warning: this is very slow
missed++;
if (missed > nMissedTolerance) {
return ((double) rank) / spectrum.getNPeaks();
}
}
rank++;
}
}
return ((double) rank) / spectrum.getNPeaks();
}
示例2: getPossiblePeptidesMap
import com.compomics.util.experiment.biology.Peptide; //导入依赖的package包/类
/**
* Returns a map of the different possible peptides for the different
* profiles.
*
* @param peptide the peptide of interest
* @param ptms the PTMs to score
* @param possibleProfiles the different profiles
*
* @return a map of the different peptides for the different profiles
*
* @throws IOException exception thrown whenever an error occurred while
* reading a protein sequence
* @throws InterruptedException exception thrown whenever an error occurred
* while reading a protein sequence
* @throws ClassNotFoundException if a ClassNotFoundException occurs
* @throws SQLException if an SQLException occurs
*/
private static HashMap<String, Peptide> getPossiblePeptidesMap(Peptide peptide, ArrayList<PTM> ptms, ArrayList<ArrayList<Integer>> possibleProfiles) throws IOException, SQLException, ClassNotFoundException, InterruptedException {
String representativePTM = ptms.get(0).getName();
HashMap<String, Peptide> result = new HashMap<String, Peptide>(possibleProfiles.size());
int peptideLength = peptide.getSequence().length();
for (ArrayList<Integer> profile : possibleProfiles) {
Peptide tempPeptide = Peptide.getNoModPeptide(peptide, ptms);
for (int pos : profile) {
int index = pos;
if (index == 0) {
index = 1;
} else if (index == peptideLength + 1) {
index = peptideLength;
}
tempPeptide.addModificationMatch(new ModificationMatch(representativePTM, true, index));
}
String profileKey = KeyUtils.getKey(profile);
result.put(profileKey, tempPeptide);
}
return result;
}
示例3: getProteinMatchKey
import com.compomics.util.experiment.biology.Peptide; //导入依赖的package包/类
/**
* Convenience method which returns the protein key of a peptide. Note:
* proteins must be set for the peptide.
*
* @param peptide the considered peptide
* @return the protein match key
*
* @throws IOException if an IOException occurs
* @throws SQLException if an SQLException occurs
* @throws ClassNotFoundException if a ClassNotFoundException occurs
* @throws InterruptedException if an InterruptedException occurs
*/
public static String getProteinMatchKey(Peptide peptide) throws IOException, SQLException, ClassNotFoundException, InterruptedException {
ArrayList<String> accessions = peptide.getParentProteinsNoRemapping();
if (accessions == null) {
throw new IllegalArgumentException("Proteins not set for peptide " + peptide.getKey() + ".");
}
HashSet<String> uniqueAccessions = new HashSet<String>(accessions);
accessions = new ArrayList<String>(uniqueAccessions);
Collections.sort(accessions);
StringBuilder key = new StringBuilder(accessions.size() * 6);
for (String accession : accessions) {
if (key.length() > 0) {
key.append(PROTEIN_KEY_SPLITTER);
}
key.append(accession);
}
return key.toString();
}
示例4: getComplementaryIonsFeatures
import com.compomics.util.experiment.biology.Peptide; //导入依赖的package包/类
/**
* Returns the ms2pip features for the complementary ions of the given
* peptide at the given charge.
*
* @param peptide the peptide
* @param charge the charge
* @param ionIndex the ion index
*
* @return the ms2pip features for the b ions
*/
public int[] getComplementaryIonsFeatures(Peptide peptide, int charge, int ionIndex) {
char[] peptideSequence = peptide.getSequence().toCharArray();
int sequenceLength = peptideSequence.length;
char[] reversedSequence = new char[sequenceLength];
for (int i = 0; i < sequenceLength; i++) {
reversedSequence[i] = peptideSequence[sequenceLength - i - 1];
}
ArrayList<ModificationMatch> modificationMatches = peptide.getModificationMatches();
ArrayList<ModificationMatch> reversedModificationMatches;
if (modificationMatches != null) {
reversedModificationMatches = new ArrayList<ModificationMatch>(modificationMatches.size());
for (ModificationMatch modificationMatch : modificationMatches) {
ModificationMatch reversedModificationMatch = new ModificationMatch(modificationMatch.getTheoreticPtm(), modificationMatch.isVariable(), sequenceLength - modificationMatch.getModificationSite() + 1);
reversedModificationMatches.add(reversedModificationMatch);
}
} else {
reversedModificationMatches = null;
}
return getIonsFeatures(reversedSequence, reversedModificationMatches, charge, ionIndex);
}
示例5: getNextPeptide
import com.compomics.util.experiment.biology.Peptide; //导入依赖的package包/类
@Override
public PeptideWithPosition getNextPeptide() throws InterruptedException {
// Get the next sequence
char[] sequence = ambiguousSequenceIterator.getNextSequence();
// Iteration finished
if (sequence == null) {
return null;
}
// Create the new peptide
Peptide peptide = proteinIteratorUtils.getPeptideFromProtein(sequence, 0, massMin, massMax);
if (peptide != null
&& (massMin == null || peptide.getMass() >= massMin)
&& (massMax == null || peptide.getMass() <= massMax)) {
return new PeptideWithPosition(peptide, 0);
} else {
return getNextPeptide();
}
}
示例6: validateProteins
import com.compomics.util.experiment.biology.Peptide; //导入依赖的package包/类
/**
* Validates a peptide depending on its protein inference status. Maps the
* peptide to proteins in case it was not done before.
*
* @param peptide the peptide
* @param sequenceMatchingPreferences the sequence matching preferences
* @param peptideMapper the peptide mapper to use for peptide to protein
* mapping
*
* @return a boolean indicating whether the peptide passed the test
*
* @throws IOException if an IOException occurs
* @throws SQLException if an SQLException occurs
* @throws ClassNotFoundException if a ClassNotFoundException occurs
* @throws InterruptedException if an InterruptedException occurs
*/
public boolean validateProteins(Peptide peptide, SequenceMatchingPreferences sequenceMatchingPreferences, PeptideMapper peptideMapper)
throws IOException, SQLException, ClassNotFoundException, InterruptedException {
ArrayList<String> accessions = peptide.getParentProteins(sequenceMatchingPreferences, peptideMapper);
if (accessions != null && accessions.size() > 1) {
boolean target = false;
boolean decoy = false;
for (String accession : accessions) {
if (SequenceFactory.getInstance().isDecoyAccession(accession)) {
decoy = true;
} else {
target = true;
}
}
if (target && decoy) {
return false;
}
}
return true;
}
示例7: setPeptide
import com.compomics.util.experiment.biology.Peptide; //导入依赖的package包/类
/**
* Sets a new peptide to match.
*
* @param peptide the new peptide
* @param possibleFragmentIons the possible fragment ions of the peptide
* @param precursorCharge the new precursor charge
* @param specificAnnotationSettings if provided, only the ions detectable
* using these settings will be selected
*/
public void setPeptide(Peptide peptide, HashMap<Integer, HashMap<Integer, ArrayList<Ion>>> possibleFragmentIons, int precursorCharge, SpecificAnnotationSettings specificAnnotationSettings) {
if (specificAnnotationSettings != null && super.specificAnnotationSettings == null
|| specificAnnotationSettings == null && super.specificAnnotationSettings != null
|| specificAnnotationSettings != null && super.specificAnnotationSettings != null && specificAnnotationSettings != super.specificAnnotationSettings
|| this.peptide == null
|| !this.peptide.getKey().equals(peptide.getKey())
|| !this.peptide.sameModificationsAs(peptide)
|| this.precursorCharge != precursorCharge) {
// Set new values
this.peptide = peptide;
this.precursorCharge = precursorCharge;
if (possibleFragmentIons == null) {
theoreticalFragmentIons = fragmentFactory.getFragmentIons(peptide, specificAnnotationSettings);
} else {
theoreticalFragmentIons = possibleFragmentIons;
}
if (massShift != 0 || massShiftNTerm != 0 || massShiftCTerm != 0) {
updateMassShifts();
}
}
}
示例8: getModificationMatches
import com.compomics.util.experiment.biology.Peptide; //导入依赖的package包/类
/**
* Parses modification matches from a modification string.
*
* @param modificationsString the modification string
*
* @return a list of modificaiton matches
*
* @throws UnsupportedEncodingException exception thrown whenever an error
* occurred while decoding the string
*/
private ArrayList<ModificationMatch> getModificationMatches(String modificationsString) throws UnsupportedEncodingException {
if (modificationsString.length() == 0) {
return new ArrayList<ModificationMatch>(0);
}
String decodedString = URLDecoder.decode(modificationsString, "utf-8");
String[] modifications = decodedString.split(Peptide.MODIFICATION_SEPARATOR);
ArrayList<ModificationMatch> modificationMatches = new ArrayList<ModificationMatch>(modifications.length);
for (String modification : modifications) {
String[] modificationSplit = modification.split(Peptide.MODIFICATION_LOCALIZATION_SEPARATOR);
String modificationName = modificationSplit[0];
Integer site = new Integer(modificationSplit[1]);
ModificationMatch modificationMatch = new ModificationMatch(modificationName, true, site);
modificationMatches.add(modificationMatch);
}
return modificationMatches;
}
示例9: getAssumptionFromLine
import com.compomics.util.experiment.biology.Peptide; //导入依赖的package包/类
/**
* Returns a Peptide Assumption from an Andromeda line.
*
* @param line the line to parse
* @param rank the rank of the assumption
*
* @return the corresponding assumption
*/
private PeptideAssumption getAssumptionFromLine(String line, int rank) {
String[] temp = line.trim().split("\t");
String[] temp1 = temp[4].split(",");
ArrayList<ModificationMatch> modMatches = new ArrayList<ModificationMatch>();
for (int aa = 0; aa < temp1.length; aa++) {
String mod = temp1[aa];
if (!mod.equals("A")) {
modMatches.add(new ModificationMatch(mod, true, aa));
}
}
String sequence = temp[0];
Peptide peptide = new Peptide(sequence, modMatches, true);
Charge charge = new Charge(Charge.PLUS, new Integer(temp[6]));
Double score = new Double(temp[1]);
Double p = FastMath.pow(10, -(score / 10));
PeptideAssumption peptideAssumption = new PeptideAssumption(peptide, rank, Advocate.andromeda.getIndex(), charge, p, fileName);
peptideAssumption.setRawScore(score);
return peptideAssumption;
}
示例10: Identify
import com.compomics.util.experiment.biology.Peptide; //导入依赖的package包/类
/**
*
* @param ms an MSnSpectrum object to compared
* @param peptide a selected peptide entry from db within given precursor
* tolerance
* @param fragment_tolerance
* @param isSequestLikeScore true:SEQUEST-like score, false:Andromeda-like
* score
* @param isCorrectMatch true:correct match if either target/UPS,
* false:incorrect match if either decoy/Pfu
* @param totalScoredPeps total number of peptides matched to a given ms
* @param correctionFactor correction factor value for SEQUEST-like scoring
* (to compute Xcorr)
* @param hasAllPossCharge true: ions with all possible charges, false: only
* up to doubly charged ions
*/
public Identify(MSnSpectrum ms, Peptide peptide, double fragment_tolerance, boolean isSequestLikeScore, boolean isCorrectMatch, int totalScoredPeps, int correctionFactor, boolean hasAllPossCharge) {
this.isSequestLikeScore = isSequestLikeScore;
this.fragment_tolerance = fragment_tolerance;
this.isCorrectMatch = isCorrectMatch;
spectrum = ms;
this.peptide = peptide;
// get theoretical ions..
HashMap<Integer, ArrayList<Ion>> product_ions_peptideA = fragmentFactory.getFragmentIons(peptide).get(0);
// add all b- ions and y-ions with uniform intensity of 50
theoretical_ions = product_ions_peptideA.get(PeptideFragmentIon.Y_ION);
theoretical_ions.addAll(product_ions_peptideA.get(PeptideFragmentIon.B_ION));
int prec = spectrum.getPrecursor().getPossibleCharges().get(0).value;
if (hasAllPossCharge) {
generate_theoretical_ions(prec);
} else if (!hasAllPossCharge && prec >= 2) {
generate_theoretical_ions(2);
} else {
generate_theoretical_ions(1);
}
this.totalScoredPeps = totalScoredPeps;
this.correctionFactor = correctionFactor;
score = match_and_score();
}
示例11: result
import com.compomics.util.experiment.biology.Peptide; //导入依赖的package包/类
private static String result(MSnSpectrum msms, double precursorTolerance, HashSet<DBEntry> peptideAndMass, double fragmentTolerance, int correctionFactor, boolean hasAllPossCharge) throws IllegalArgumentException, IOException, MzMLUnmarshallerException {
String res = "";
HashMap<Peptide, Boolean> allSelectedPeps = getSelectedTheoPeps(msms, precursorTolerance, peptideAndMass); // select peptides within a given precursor tolerance
int scoredPeps = allSelectedPeps.size();
ArrayList<Identify> sequestResults = new ArrayList<Identify>(),
andromedaResults = new ArrayList<Identify>();
// for every peptide... calculate each score...
for (Peptide selectedPep : allSelectedPeps.keySet()) {
Identify toCalculateSequest = new Identify(msms, selectedPep, fragmentTolerance, true, allSelectedPeps.get(selectedPep), scoredPeps, correctionFactor, hasAllPossCharge),
toCalculateAndromeda = new Identify(msms, selectedPep, fragmentTolerance, false, allSelectedPeps.get(selectedPep), scoredPeps, correctionFactor, hasAllPossCharge);
if (toCalculateSequest.getScore() != Double.NEGATIVE_INFINITY) {
sequestResults.add(toCalculateSequest);
andromedaResults.add(toCalculateAndromeda);
}
}
if (!sequestResults.isEmpty()) {
HashSet<Identify> theBestSEQUESTResults = getBestResult(sequestResults),
theBestAndromedaResults = getBestResult(andromedaResults);
res = printInfo(theBestAndromedaResults, theBestSEQUESTResults);
}
return res;
}
示例12: getDBEntries
import com.compomics.util.experiment.biology.Peptide; //导入依赖的package包/类
/**
* This method load all sequences in a memory
*
* @param databaseName
* @return
*/
private static HashSet<DBEntry> getDBEntries(String databaseName) throws IOException {
HashSet<DBEntry> dbEntries = new HashSet<DBEntry>();
DBLoader loader = DBLoaderLoader.loadDB(new File(databaseName));
Protein protein = null;
// get a crossLinkerName object
while ((protein = loader.nextProtein()) != null) {
String sequence = protein.getSequence().getSequence();
String descrp = protein.getHeader().getDescription(),
acc = protein.getHeader().getAccession();
Peptide tmpPep = new Peptide(sequence, new ArrayList<ModificationMatch>());
double tmpPepMass = tmpPep.getMass();
DBEntry dbEntry = new DBEntry(tmpPep, descrp, acc, tmpPepMass);
dbEntries.add(dbEntry);
}
return dbEntries;
}
示例13: getSelectedTheoPeps
import com.compomics.util.experiment.biology.Peptide; //导入依赖的package包/类
private static HashMap<Peptide, Boolean> getSelectedTheoPeps(MSnSpectrum msms, double precursorTolerance, HashSet<DBEntry> dbEntries) throws IOException, IllegalArgumentException {
// select peptides to be compared...
HashMap<Peptide, Boolean> allTheoPeps = new HashMap< Peptide, Boolean>();
for (DBEntry dbEntry : dbEntries) {
Peptide p = dbEntry.getPeptide();
double peptideMass = dbEntry.getPeptideMass();
String acc = dbEntry.getProteinAccession(),
descrp = dbEntry.getProteinDescription();
double tmpMS1Tolerance = CalculateMS1Err.getMS1Err(true, peptideMass, msms.getPrecursor().getMass(msms.getPrecursor().getPossibleCharges().get(0).value));
boolean isCorrect = false;
if (Math.abs(tmpMS1Tolerance) <= precursorTolerance && !descrp.contains("contaminant") && acc.contains("ups")) {
isCorrect = true;
allTheoPeps.put(p, isCorrect);
} else if (Math.abs(tmpMS1Tolerance) <= precursorTolerance && !descrp.contains("contaminant")) {
isCorrect = false;
allTheoPeps.put(p, isCorrect);
}
}
return allTheoPeps;
}
示例14: getScore
import com.compomics.util.experiment.biology.Peptide; //导入依赖的package包/类
/**
* Scores the match between the given peptide and spectrum using the
* complementarity of the matched peaks. For every residue, a list of
* matched peaks is established and if any is found, the score per residue
* is the log of the number of matched ions. The peptide score is the
* average of the residue scores.
*
* @param peptide the peptide of interest
* @param spectrum the spectrum of interest
* @param annotationPreferences the general spectrum annotation preferences
* @param specificAnnotationPreferences the annotation preferences specific to this psm
* @param peptideSpectrumAnnotator the spectrum annotator to use
*
* @return the score of the match
*
* @throws java.lang.InterruptedException exception thrown if the thread is
* interrupted
* @throws org.apache.commons.math.MathException exception thrown if a math exception occurred when estimating the noise level
*/
public double getScore(Peptide peptide, MSnSpectrum spectrum, AnnotationSettings annotationPreferences, SpecificAnnotationSettings specificAnnotationPreferences, PeptideSpectrumAnnotator peptideSpectrumAnnotator) throws InterruptedException, MathException {
int sequenceLength = peptide.getSequence().length();
ArrayList<IonMatch> matches = peptideSpectrumAnnotator.getSpectrumAnnotation(annotationPreferences, specificAnnotationPreferences,
spectrum, peptide);
HashMap<Integer, Double> residueToMatchesMap = new HashMap<Integer, Double>(sequenceLength);
for (int i = 1; i <= sequenceLength; i++) {
residueToMatchesMap.put(i, 0.0);
}
for (IonMatch ionMatch : matches) {
Ion ion = ionMatch.ion;
if (ion instanceof PeptideFragmentIon) {
PeptideFragmentIon peptideFragmentIon = (PeptideFragmentIon) ion;
int number = peptideFragmentIon.getNumber();
residueToMatchesMap.put(number, residueToMatchesMap.get(number) + 1);
}
}
ArrayList<Double> scorePerResidue = new ArrayList<Double>(residueToMatchesMap.size());
for (int number = 1; number <= sequenceLength; number++) {
Double nIons = residueToMatchesMap.get(number);
if (nIons != null) {
scorePerResidue.add(FastMath.log(nIons) / log2);
}
}
double mean = 0;
if (!scorePerResidue.isEmpty()) {
mean = BasicMathFunctions.mean(scorePerResidue);
}
return Math.pow(2, mean);
}
示例15: getScore
import com.compomics.util.experiment.biology.Peptide; //导入依赖的package包/类
/**
* Scores the match between the given peptide and spectrum using an m/z
* fidelity score. Returns the average over the peptide sequence of the
* minimal mass error of the ions annotating an amino acid.
*
* @param peptide the peptide of interest
* @param spectrum the spectrum of interest
* @param annotationPreferences the general spectrum annotation preferences
* @param specificAnnotationPreferences the annotation preferences specific to this psm
* @param peptideSpectrumAnnotator the spectrum annotator to use
*
* @return the score of the match
*
* @throws java.lang.InterruptedException exception thrown if the thread is
* interrupted
* @throws org.apache.commons.math.MathException exception thrown if a math exception occurred when estimating the noise level
*/
public double getScore(Peptide peptide, MSnSpectrum spectrum, AnnotationSettings annotationPreferences, SpecificAnnotationSettings specificAnnotationPreferences, PeptideSpectrumAnnotator peptideSpectrumAnnotator) throws InterruptedException, MathException {
int sequenceLength = peptide.getSequence().length();
HashMap<Integer, Double> aaDeviations = new HashMap(sequenceLength);
for (int i = 1; i <= sequenceLength; i++) {
aaDeviations.put(i, specificAnnotationPreferences.getFragmentIonAccuracyInDa(spectrum.getMaxMz()));
}
ArrayList<IonMatch> matches = peptideSpectrumAnnotator.getSpectrumAnnotation(annotationPreferences, specificAnnotationPreferences,
spectrum, peptide);
for (IonMatch ionMatch : matches) {
Ion ion = ionMatch.ion;
if (ion instanceof PeptideFragmentIon) {
PeptideFragmentIon peptideFragmentIon = (PeptideFragmentIon) ion;
int number = peptideFragmentIon.getNumber();
double error = aaDeviations.get(number),
tempError = Math.abs(ionMatch.getAbsoluteError());
if (tempError < error) {
aaDeviations.put(number, tempError);
}
}
}
ArrayList<Double> mzDeviations = new ArrayList<Double>(aaDeviations.values());
if (mzDeviations.isEmpty()) {
return specificAnnotationPreferences.getFragmentIonAccuracyInDa(spectrum.getMaxMz());
}
return BasicMathFunctions.mean(mzDeviations);
}