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