Skip to content

Commit

Permalink
Fixes cdk/depict#76. We do not like -C=CO as an abbreviation.
Browse files Browse the repository at this point in the history
  • Loading branch information
johnmay authored and egonw committed Sep 29, 2023
1 parent a089e50 commit 125505c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -761,10 +761,12 @@ else if (effectiveDegree(attach, allCrossingBonds) <= 1 &&
// reject if no symbols
// reject if no bonds (<1), except if all symbols are identical... (HashSet.size==1)
// reject if more than 2 bonds
// reject if double bond attachement
if (adjGroupMap.isEmpty() ||
newbonds.size() < 1 && !options.contains(Option.ALLOW_SINGLETON) ||
newbonds.size() > 1 && !options.contains(Option.AUTO_CONTRACT_LINKERS) ||
newbonds.size() > 2)
newbonds.size() > 2 ||
newbonds.size() == 1 && newbonds.iterator().next().getOrder() != IBond.Order.SINGLE)
continue;

if (isCC(attach, xbonds, adjGroupMap))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -819,6 +819,17 @@ void HOOH() throws Exception {
assertThat(sgroups.get(0).getSubscript(), is("HOOH"));
}

@Test
void shouldNotPartiallyContractKetene() throws Exception {
Abbreviations factory = new Abbreviations();
IAtomContainer mol = smi("c1ccccc1CC=C=O");
factory.with(Abbreviations.Option.AUTO_CONTRACT_HETERO);
factory.with(Abbreviations.Option.AUTO_CONTRACT_TERMINAL);
List<Sgroup> sgroups = factory.generate(mol);
assertThat(sgroups.size(), is(0));
}


@Test
void multipleDisconnectedAbbreviations() throws Exception {
String smi = "ClCCl.Cl[Pd]Cl.[Fe+2].c1ccc(P([c-]2cccc2)c2ccccc2)cc1.c1ccc(P([c-]2cccc2)c2ccccc2)cc1";
Expand Down

0 comments on commit 125505c

Please sign in to comment.