User 7f33ec9a5c
06-10-2009 05:15:31
Hi,
I am trying to orient 2D smiles depictions so a steroid core always appears in the same orientation. I also want to change some of the stereocenters so that they show explicit hydrogens with the wedge bonds attached to the hydrogens (even though the hydrogens are implicit in the original smiles). I'm sure this is a pretty common request, and I just need to be pointed at the documentation or an example.
I'm not good at navigating the ChemAxon documentation, so if you could just point me to the appropriate example, or list the API calls I need, I should be able to sort the rest out.
So far my code, taken from your depiction example and changed to C# looks like this, which does the depiction as I would like, but does not orient the scaffold based on the steroid core.
{...
Molecule mol = MolImporter.importMol(sMolString);
// Calculate the coordinates if needed (for example
// if the input is SMILES)
if (mol.getDim() == 0)
{
mol.clean(2, "O1");
}
//flip the depiction around to match a standard steroid core:
Molecule oScaffold = MolImporter.importMol(SteroidCore);
mol = HitDisplayUtil.getScaffoldOrientatedHit(oScaffold, mol);
// Generating the image
byte[] b = mol.toBinFormat(sFormat);
//write the response
Response.Clear();
Response.ContentType = "image/" + sType;
Response.BinaryWrite(b);
...}
public string SteroidCore
{
get
{
StringBuilder oSB = new StringBuilder();
oSB.Append("<?xml version=\"1.0\" ?>");
oSB.Append("<cml>");
oSB.Append("<MDocument>");
oSB.Append(" <MChemicalStruct>");
oSB.Append(" <molecule molID=\"m1\">");
oSB.Append(" <atomArray>");
oSB.Append(" <atom id=\"a1\" elementType=\"C\"");
oSB.Append(" x2=\"-5.059999942779541\" y2=\"-1.154966052124717\" />");
oSB.Append(" <atom id=\"a2\" elementType=\"C\"");
oSB.Append(" x2=\"-6.3936692838277995\" y2=\"-1.9249829926837574\" />");
oSB.Append(" <atom id=\"a3\" elementType=\"C\"");
oSB.Append(" x2=\"-6.3936692838277995\" y2=\"-3.4650168738018383\" />");
oSB.Append(" <atom id=\"a4\" elementType=\"C\"");
oSB.Append(" x2=\"-5.059999942779541\" y2=\"-4.235033814360879\" />");
oSB.Append(" <atom id=\"a5\" elementType=\"C\"");
oSB.Append(" x2=\"-3.7263306017312825\" y2=\"-3.4650168738018383\" />");
oSB.Append(" <atom id=\"a6\" elementType=\"C\"");
oSB.Append(" x2=\"-3.7263306017312825\" y2=\"-1.9249829926837574\" />");
oSB.Append(" <atom id=\"a7\" elementType=\"C\"");
oSB.Append(" x2=\"-2.392661260683024\" y2=\"-1.154966052124717\" />");
oSB.Append(" <atom id=\"a8\" elementType=\"C\"");
oSB.Append(" x2=\"-2.392661260683024\" y2=\"-4.235033814360879\" />");
oSB.Append(" <atom id=\"a9\" elementType=\"C\"");
oSB.Append(" x2=\"-1.0589919196347655\" y2=\"-3.4650168738018383\" />");
oSB.Append(" <atom id=\"a10\" elementType=\"C\"");
oSB.Append(" x2=\"-1.0589919196347655\" y2=\"-1.9249829926837574\" />");
oSB.Append(" <atom id=\"a11\" elementType=\"C\"");
oSB.Append(" x2=\"-1.0589919196347655\" y2=\"1.1550847695524045\" />");
oSB.Append(" <atom id=\"a12\" elementType=\"C\"");
oSB.Append(" x2=\"-2.392661260683024\" y2=\"0.385067828993364\" />");
oSB.Append(" <atom id=\"a13\" elementType=\"C\"");
oSB.Append(" x2=\"0.27467742141349305\" y2=\"-1.154966052124717\" />");
oSB.Append(" <atom id=\"a14\" elementType=\"C\"");
oSB.Append(" x2=\"0.27467742141349305\" y2=\"0.385067828993364\" />");
oSB.Append(" <atom id=\"a15\" elementType=\"C\"");
oSB.Append(" x2=\"1.739294644214355\" y2=\"0.8608672774056125\" />");
oSB.Append(" <atom id=\"a16\" elementType=\"C\"");
oSB.Append(" x2=\"1.7393112772802286\" y2=\"-1.6308565478795223\" />");
oSB.Append(" <atom id=\"a17\" elementType=\"C\"");
oSB.Append(" x2=\"2.6444550002058693\" y2=\"-0.3850399141384929\" />");
oSB.Append(" <atom id=\"a18\" elementType=\"H\"");
oSB.Append(" x2=\"0.43565998491724905\" y2=\"-2.6865288533992056\" />");
oSB.Append(" <atom id=\"a19\" elementType=\"H\"");
oSB.Append(" x2=\"-2.392661260683024\" y2=\"-2.694966052124717\" />");
oSB.Append(" <atom id=\"a20\" elementType=\"H\"");
oSB.Append(" x2=\"-1.0589919196347655\" y2=\"-0.38498299268375735\" />");
oSB.Append(" <atom id=\"a21\" elementType=\"H\"");
oSB.Append(" x2=\"-3.7263306017312825\" y2=\"-0.38498299268375735\" />");
oSB.Append(" <atom id=\"a22\" elementType=\"H\"");
oSB.Append(" x2=\"0.27467742141349316\" y2=\"1.925067828993364\" />");
oSB.Append(" <atom id=\"a23\" elementType=\"C\"");
oSB.Append(" x2=\"-7.72735329596503\" y2=\"-4.23500840347573\" />");
oSB.Append(" <atom id=\"a24\" elementType=\"H\"");
oSB.Append(" x2=\"-7.881195056312965\" y2=\"-3.066435544343956\" />");
oSB.Append(" </atomArray>");
oSB.Append(" <bondArray>");
oSB.Append(" <bond atomRefs2=\"a1 a2\" order=\"1\" />");
oSB.Append(" <bond atomRefs2=\"a1 a6\" order=\"1\" />");
oSB.Append(" <bond atomRefs2=\"a2 a3\" order=\"1\" />");
oSB.Append(" <bond atomRefs2=\"a3 a4\" order=\"1\" />");
oSB.Append(" <bond atomRefs2=\"a4 a5\" order=\"1\" />");
oSB.Append(" <bond atomRefs2=\"a7 a6\" order=\"1\" />");
oSB.Append(" <bond atomRefs2=\"a6 a5\" order=\"1\" />");
oSB.Append(" <bond atomRefs2=\"a5 a8\" order=\"1\" />");
oSB.Append(" <bond atomRefs2=\"a8 a9\" order=\"1\" />");
oSB.Append(" <bond atomRefs2=\"a9 a10\" order=\"1\" />");
oSB.Append(" <bond atomRefs2=\"a10 a13\" order=\"1\" />");
oSB.Append(" <bond atomRefs2=\"a7 a10\" order=\"1\" />");
oSB.Append(" <bond atomRefs2=\"a12 a7\" order=\"1\" />");
oSB.Append(" <bond atomRefs2=\"a11 a12\" order=\"1\" />");
oSB.Append(" <bond atomRefs2=\"a11 a14\" order=\"1\" />");
oSB.Append(" <bond atomRefs2=\"a13 a16\" order=\"1\" />");
oSB.Append(" <bond atomRefs2=\"a14 a13\" order=\"1\" />");
oSB.Append(" <bond atomRefs2=\"a15 a14\" order=\"1\" />");
oSB.Append(" <bond atomRefs2=\"a15 a17\" order=\"1\" />");
oSB.Append(" <bond atomRefs2=\"a16 a17\" order=\"1\" />");
oSB.Append(" <bond atomRefs2=\"a13 a18\" order=\"1\">");
oSB.Append(" <bondStereo>H</bondStereo>");
oSB.Append(" </bond>");
oSB.Append(" <bond atomRefs2=\"a7 a19\" order=\"1\">");
oSB.Append(" <bondStereo>H</bondStereo>");
oSB.Append(" </bond>");
oSB.Append(" <bond atomRefs2=\"a10 a20\" order=\"1\">");
oSB.Append(" <bondStereo>W</bondStereo>");
oSB.Append(" </bond>");
oSB.Append(" <bond atomRefs2=\"a6 a21\" order=\"1\">");
oSB.Append(" <bondStereo>W</bondStereo>");
oSB.Append(" </bond>");
oSB.Append(" <bond atomRefs2=\"a14 a22\" order=\"1\">");
oSB.Append(" <bondStereo>W</bondStereo>");
oSB.Append(" </bond>");
oSB.Append(" <bond atomRefs2=\"a3 a23\" order=\"1\">");
oSB.Append(" <bondStereo>W</bondStereo>");
oSB.Append(" </bond>");
oSB.Append(" <bond atomRefs2=\"a3 a24\" order=\"1\">");
oSB.Append(" <bondStereo>H</bondStereo>");
oSB.Append(" </bond>");
oSB.Append(" </bondArray>");
oSB.Append(" </molecule>");
oSB.Append(" </MChemicalStruct>");
oSB.Append("</MDocument>");
oSB.Append("</cml>");
return oSB.ToString();
}
}