@Test public void testDLStereochemistryInvertedNaturalOnCarbohydrate1() throws ComponentGenerationException, StructureBuildingException{ BuildState state = new BuildState(mock(NameToStructureConfig.class)); Fragment f = state.fragManager.buildSMILES("N[C@@H](C)C"); Element carbohydrateEl = new TokenEl(GROUP_EL); carbohydrateEl.addAttribute(new Attribute(NATURALENTISOPPOSITE_ATR, "yes")); carbohydrateEl.setFrag(f); int parityBefore = f.getAtomByID(2).getAtomParity().getParity(); ComponentProcessor processor = new ComponentProcessor(state, mock(SuffixApplier.class)); processor.applyDlStereochemistryToCarbohydrate(carbohydrateEl, "l"); assertEquals(parityBefore, f.getAtomByID(2).getAtomParity().getParity()); }
void applyDlStereochemistryToCarbohydrate(Element carbohydrateEl, String dlStereochemistryValue) throws ComponentGenerationException { Fragment carbohydrate = carbohydrateEl.getFrag(); List<Atom> atomList = carbohydrate.getAtomList(); List<Atom> atomsWithParities = new ArrayList<Atom>(); for (Atom atom : atomList) { if (atom.getAtomParity()!=null){ atomsWithParities.add(atom); } } if (atomsWithParities.isEmpty()){ throw new ComponentGenerationException("D/L stereochemistry :" + dlStereochemistryValue + " found before achiral carbohydrate"); } if (dlStereochemistryValue.equals("dl")){ for (Atom atom : atomsWithParities) { atom.setAtomParity(null); } } else{ boolean invert; if (dlStereochemistryValue.equals("d") || dlStereochemistryValue.equals("dg")){ invert = false; } else if (dlStereochemistryValue.equals("l") || dlStereochemistryValue.equals("lg")){ invert = true; } else{ throw new ComponentGenerationException("Unexpected value for D/L stereochemistry found before carbohydrate: " + dlStereochemistryValue ); } if ("yes".equals(carbohydrateEl.getAttributeValue(NATURALENTISOPPOSITE_ATR))){ invert = !invert; } if (invert) { for (Atom atom : atomsWithParities) { atom.getAtomParity().setParity(-atom.getAtomParity().getParity()); } } } }
ComponentProcessor { void applyDlStereochemistryToCarbohydrate(Element carbohydrateEl, String dlStereochemistryValue) throws ComponentGenerationException { Fragment carbohydrate = carbohydrateEl.getFrag(); List<Atom> atomList = carbohydrate.getAtomList(); List<Atom> atomsWithParities = new ArrayList<Atom>(); for (Atom atom : atomList) { if (atom.getAtomParity()!=null){ atomsWithParities.add(atom); } } if (atomsWithParities.isEmpty()){ throw new ComponentGenerationException("D/L stereochemistry :" + dlStereochemistryValue + " found before achiral carbohydrate"); } if (dlStereochemistryValue.equals("dl")){ for (Atom atom : atomsWithParities) { atom.setAtomParity(null); } } else{ boolean invert; if (dlStereochemistryValue.equals("d") || dlStereochemistryValue.equals("dg")){ invert = false; } else if (dlStereochemistryValue.equals("l") || dlStereochemistryValue.equals("lg")){ invert = true; } else{ throw new ComponentGenerationException("Unexpected value for D/L stereochemistry found before carbohydrate: " + dlStereochemistryValue ); } if ("yes".equals(carbohydrateEl.getAttributeValue(NATURALENTISOPPOSITE_ATR))){ invert = !invert; } if (invert) { for (Atom atom : atomsWithParities) { atom.getAtomParity().setParity(-atom.getAtomParity().getParity()); } } } } }
ComponentProcessor { void applyDlStereochemistryToCarbohydrate(Element carbohydrateEl, String dlStereochemistryValue) throws ComponentGenerationException { Fragment carbohydrate = carbohydrateEl.getFrag(); List<Atom> atomList = carbohydrate.getAtomList(); List<Atom> atomsWithParities = new ArrayList<Atom>(); for (Atom atom : atomList) { if (atom.getAtomParity()!=null){ atomsWithParities.add(atom); } } if (atomsWithParities.isEmpty()){ throw new ComponentGenerationException("D/L stereochemistry :" + dlStereochemistryValue + " found before achiral carbohydrate"); } if (dlStereochemistryValue.equals("dl")){ for (Atom atom : atomsWithParities) { atom.setAtomParity(null); } } else{ boolean invert; if (dlStereochemistryValue.equals("d") || dlStereochemistryValue.equals("dg")){ invert = false; } else if (dlStereochemistryValue.equals("l") || dlStereochemistryValue.equals("lg")){ invert = true; } else{ throw new ComponentGenerationException("Unexpected value for D/L stereochemistry found before carbohydrate: " + dlStereochemistryValue ); } if ("yes".equals(carbohydrateEl.getAttributeValue(NATURALENTISOPPOSITE_ATR))){ invert = !invert; } if (invert) { for (Atom atom : atomsWithParities) { atom.getAtomParity().setParity(-atom.getAtomParity().getParity()); } } } } ComponentProcessor(BuildState state, SuffixApplier suffixApplier); }
ComponentProcessor { void applyDlStereochemistryToCarbohydrate(Element carbohydrateEl, String dlStereochemistryValue) throws ComponentGenerationException { Fragment carbohydrate = carbohydrateEl.getFrag(); List<Atom> atomList = carbohydrate.getAtomList(); List<Atom> atomsWithParities = new ArrayList<Atom>(); for (Atom atom : atomList) { if (atom.getAtomParity()!=null){ atomsWithParities.add(atom); } } if (atomsWithParities.isEmpty()){ throw new ComponentGenerationException("D/L stereochemistry :" + dlStereochemistryValue + " found before achiral carbohydrate"); } if (dlStereochemistryValue.equals("dl")){ for (Atom atom : atomsWithParities) { atom.setAtomParity(null); } } else{ boolean invert; if (dlStereochemistryValue.equals("d") || dlStereochemistryValue.equals("dg")){ invert = false; } else if (dlStereochemistryValue.equals("l") || dlStereochemistryValue.equals("lg")){ invert = true; } else{ throw new ComponentGenerationException("Unexpected value for D/L stereochemistry found before carbohydrate: " + dlStereochemistryValue ); } if ("yes".equals(carbohydrateEl.getAttributeValue(NATURALENTISOPPOSITE_ATR))){ invert = !invert; } if (invert) { for (Atom atom : atomsWithParities) { atom.getAtomParity().setParity(-atom.getAtomParity().getParity()); } } } } ComponentProcessor(BuildState state, SuffixApplier suffixApplier);  }
ComponentProcessor { void applyDlStereochemistryToCarbohydrate(Element carbohydrateEl, String dlStereochemistryValue) throws ComponentGenerationException { Fragment carbohydrate = carbohydrateEl.getFrag(); List<Atom> atomList = carbohydrate.getAtomList(); List<Atom> atomsWithParities = new ArrayList<Atom>(); for (Atom atom : atomList) { if (atom.getAtomParity()!=null){ atomsWithParities.add(atom); } } if (atomsWithParities.isEmpty()){ throw new ComponentGenerationException("D/L stereochemistry :" + dlStereochemistryValue + " found before achiral carbohydrate"); } if (dlStereochemistryValue.equals("dl")){ for (Atom atom : atomsWithParities) { atom.setAtomParity(null); } } else{ boolean invert; if (dlStereochemistryValue.equals("d") || dlStereochemistryValue.equals("dg")){ invert = false; } else if (dlStereochemistryValue.equals("l") || dlStereochemistryValue.equals("lg")){ invert = true; } else{ throw new ComponentGenerationException("Unexpected value for D/L stereochemistry found before carbohydrate: " + dlStereochemistryValue ); } if ("yes".equals(carbohydrateEl.getAttributeValue(NATURALENTISOPPOSITE_ATR))){ invert = !invert; } if (invert) { for (Atom atom : atomsWithParities) { atom.getAtomParity().setParity(-atom.getAtomParity().getParity()); } } } } ComponentProcessor(BuildState state, SuffixApplier suffixApplier);   }