All Downloads are FREE. Search and download functionalities are using the official Maven repository.

se.lth.immun.chem.Ion Maven / Gradle / Ivy

Go to download

Library for general purpose in silico chemistry, mainly intended for mass spectrometry proteomics computations.

There is a newer version: 1.3.3
Show newest version
package se.lth.immun.chem;

public class Ion {
	
	public T 		molecule;
	public int 	numExtraProtons		= 0;
	public int 	numExtraElectrons	= 0;
	
	public Ion(T molecule, int numExtraProtons) {
		this.molecule = molecule;
		this.numExtraProtons = numExtraProtons;
	}
	
	public Ion(T molecule, int numExtraProtons, int numExtraElectrons) {
		this.molecule = molecule;
		this.numExtraProtons = numExtraProtons;
		this.numExtraElectrons = numExtraElectrons;
	}
	
	public double mz() {
		double mass = molecule.monoisotopicMass();
		mass += numExtraProtons * Constants.PROTON_WEIGHT + numExtraElectrons * Constants.ELECTRON_WEIGHT;
		return mass / Math.abs(numExtraProtons - numExtraElectrons);
	}
	
	public int sign() {
		return numExtraProtons > numExtraElectrons ? 1 : -1;
	}
	
	public static double mz(IMolecule molecule, int numExtraProtons) {
		return mz(molecule, numExtraProtons, 0);
	}
	public static double mz(IMolecule molecule, int numExtraProtons, int numExtraElectrons) {
		double mass = molecule.monoisotopicMass();
		mass += numExtraProtons * Constants.PROTON_WEIGHT + numExtraElectrons * Constants.ELECTRON_WEIGHT;
		return mass / Math.abs(numExtraProtons - numExtraElectrons);
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy