@Test public void protonatePhenolate() throws Exception { IChemObjectBuilder bldr = SilentChemObjectBuilder.getInstance(); IMolecularFormula mf = MolecularFormulaManipulator.getMolecularFormula("[C6H5O]-", bldr); assertTrue(MolecularFormulaManipulator.adjustProtonation(mf, +1)); assertThat(MolecularFormulaManipulator.getString(mf), is("C6H6O")); assertThat(mf.getCharge(), is(0)); assertThat(mf.getIsotopeCount(), is(3)); }
@Test public void protonatePhenolateMajorIsotopes() throws Exception { IChemObjectBuilder bldr = SilentChemObjectBuilder.getInstance(); IMolecularFormula mf = MolecularFormulaManipulator.getMajorIsotopeMolecularFormula("[C6H5O]-", bldr); assertTrue(MolecularFormulaManipulator.adjustProtonation(mf, +1)); assertThat(MolecularFormulaManipulator.getString(mf), is("C6H6O")); assertThat(mf.getCharge(), is(0)); assertThat(mf.getIsotopeCount(), is(3)); }
@Test public void prontateChloride() throws Exception { IChemObjectBuilder bldr = SilentChemObjectBuilder.getInstance(); IMolecularFormula mf = MolecularFormulaManipulator.getMolecularFormula("[Cl]-", bldr); assertTrue(MolecularFormulaManipulator.adjustProtonation(mf, +1)); assertThat(MolecularFormulaManipulator.getString(mf), is("ClH")); assertThat(mf.getCharge(), is(0)); assertThat(mf.getIsotopeCount(), is(2)); }
@Test public void deprontateHCl() throws Exception { IChemObjectBuilder bldr = SilentChemObjectBuilder.getInstance(); IMolecularFormula mf = MolecularFormulaManipulator.getMolecularFormula("HCl", bldr); assertTrue(MolecularFormulaManipulator.adjustProtonation(mf, -1)); assertThat(MolecularFormulaManipulator.getString(mf), is("[Cl]-")); assertThat(mf.getCharge(), is(-1)); assertThat(mf.getIsotopeCount(), is(1)); }
@Test public void deprotonatePhenol() throws Exception { IChemObjectBuilder bldr = SilentChemObjectBuilder.getInstance(); IMolecularFormula mf = MolecularFormulaManipulator.getMolecularFormula("C6H6O", bldr); assertTrue(MolecularFormulaManipulator.adjustProtonation(mf, -1)); assertThat(MolecularFormulaManipulator.getString(mf), is("[C6H5O]-")); assertThat(mf.getCharge(), is(-1)); }
@Test public void deprontateChloride() throws Exception { IChemObjectBuilder bldr = SilentChemObjectBuilder.getInstance(); IMolecularFormula mf = MolecularFormulaManipulator.getMolecularFormula("[Cl]-", bldr); assertFalse(MolecularFormulaManipulator.adjustProtonation(mf, -1)); }
@Test public void protonateDeuteratedPhenolate() throws Exception { IChemObjectBuilder bldr = SilentChemObjectBuilder.getInstance(); IMolecularFormula mf = bldr.newInstance(IMolecularFormula.class); // [C6DH4O]- (parser not good enough ATM so need to create like this) IIsotope deuterium = Isotopes.getInstance().getIsotope("H", 2); IIsotope hydrogen = Isotopes.getInstance().getMajorIsotope(1); mf.addIsotope(deuterium, 1); mf.addIsotope(hydrogen, 4); mf.addIsotope(Isotopes.getInstance().getMajorIsotope(6), 6); mf.addIsotope(Isotopes.getInstance().getMajorIsotope(8), 1); mf.setCharge(-1); assertTrue(MolecularFormulaManipulator.adjustProtonation(mf, +1)); assertThat(MolecularFormulaManipulator.getString(mf), is("C6H6O")); assertThat(mf.getCharge(), is(0)); assertThat(mf.getIsotopeCount(), is(4)); assertThat(mf.getIsotopeCount(deuterium), is(1)); assertThat(mf.getIsotopeCount(hydrogen), is(5)); }
@Test public void testGetIsotopes_IMolecularFormula_deprotonate() { IsotopePatternGenerator isogen = new IsotopePatternGenerator(.1); IMolecularFormula mf1 = MolecularFormulaManipulator.getMolecularFormula("C6H12O6", builder); MolecularFormulaManipulator.adjustProtonation(mf1, -1); IsotopePattern ip1 = isogen.getIsotopes(mf1); Assert.assertEquals(1, ip1.getNumberOfIsotopes()); isogen = new IsotopePatternGenerator(.1); IMolecularFormula mf2 = MolecularFormulaManipulator.getMolecularFormula("C6H11O6", builder); IsotopePattern ip2 = isogen.getIsotopes(mf2); Assert.assertEquals(1, ip2.getNumberOfIsotopes()); Assert.assertEquals(ip1.getIsotope(0).getMass(), ip2.getIsotope(0).getMass(), 0.001); }