se.lth.immun.chem.PeptideUtil Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of Proteins Show documentation
Show all versions of Proteins Show documentation
Library for general purpose in silico chemistry, mainly intended for mass spectrometry proteomics computations.
package se.lth.immun.chem;
import java.util.ArrayList;
import java.util.List;
public class PeptideUtil {
/**
* @param args
*/
public static void main(String[] args) {
// Example usage of functions:
String test = "ADGGCK";
IAminoAcid[] aas = new IAminoAcid[test.length()];
for (int ix=0;ix ion = new Ion(pf,charge);
System.out.println(""+pf.fragmentType+""+pf.ordinal+"^"+charge+" "+ion.mz());
}
}
double mz=307.2;
double tol=0.5;
System.out.println(matchedIonsAsString(matchingIons(possibleYAndBIons(standardPeptideFromString(test),2),mz,tol)));
}
public static Peptide standardPeptideFromString(String sequence)
{
IAminoAcid[] aas = new IAminoAcid[sequence.length()];
for (int i=0;i> possibleYAndBIons(Peptide p, double maxCharge)
{
EPeptideFragment[] fragments = {EPeptideFragment.y, EPeptideFragment.b};
return possibleIons(p, fragments,maxCharge);
}
public static List> possibleIons(Peptide p, EPeptideFragment[] fragments, double maxCharge)
{
ArrayList> ions = new ArrayList>();
PeptideFragment[] frags = p.getFragments(fragments);
for (PeptideFragment pf:frags)
{
for (int charge=1;charge<=maxCharge;charge++)
{
ions.add(new Ion(pf,charge));
}
}
return ions;
}
public static List> matchingIons(List> ions, double peakMz, double mzTolerance)
{
ArrayList> matchedIons = new ArrayList>();
for (Ion ion:ions)
{
if (Math.abs(ion.mz()-peakMz)> ions)
{
String s = "";
for (int i=0;i0) s+=",";
s+=""+ions.get(i).molecule.fragmentType+""+ions.get(i).molecule.ordinal+"^"+ions.get(i).numExtraProtons;
}
return s;
}
}