Hit highlighting and alignment for image export

User 8688ffe688

22-05-2012 20:27:46

I'm trying to create images of hit molecules with alignment and hit highlighting for substructure searching.  Code snippet below.


JChemSearch jcS = new JChemSearch();


HitColoringAndAlignmentOptions opts = new HitColoringAndAlignmentOptions();


opts.coloring = true;


opts.alignmentMode = HitColoringAndAlignmentOptions.ALIGNMENT_ROTATE;


//array if cd_ids


int idArr[] = new int[50];


for (int i = 0; i < 50; i++) {


    idArr = jcS.getResult(i);


}


ArrayList dataValues = new ArrayList();


Molecule[] molArr = jcS.getHitsAsMolecules(idArr, opts, dataFieldNames, dataValues);


What is the best way to take the Molecule array and create images with alignment and hit highlighting?  I'm able to do this using MarvinView by exporting mrv type but when I export any image type the alignment and hit highlighting are lost.  Any tips would be appreciated.

User 8688ffe688

24-05-2012 19:43:37

Looks like hit highlighting does not work when you have a transparent background.  I switched to white background and highlighting of substructure is viewable.

ChemAxon f052bdfe3c

24-05-2012 20:02:51

Does it solve your problem or do you need transparent background?


Best Regards,


Efi

ChemAxon 5433b8e56b

26-05-2012 01:28:37

Hi,


please check this code snippet:


    Molecule mol = MolImporter.importMol("ClOCCC1=CC=CN=C1");
    for (int i=0; i<2; i++){
        mol.getAtom(i).setSetSeq(1);
    }
    MDocument doc = new MDocument(mol);
    doc.setAtomSetRGB(1, 0xff00ff);

    String param = "png:w100,h100,setcolors,transbg";
    
    FileOutputStream out = new FileOutputStream(new File("exported.png"));
    MolExporter exporter = new MolExporter(out, param);
    exporter.write(mol);
    exporter.close();

This is works for me, and generates a transparent png with the given coloring. (the setting of atomsetcoloring is sort of the same what JChemSearch does when gives back the colored result, but it is simplified to change only the color of the first two atom in the structure)


JChemSearch gives back the structure with atom and bond sets properly set based on your code snippet. Image export need to add "setcolors" to its export options string to draw the color sets properly colored.


I do not know exactly why it is colored when you set the white background, but I assume this is a side effect only.


Which image format did you use, and how did you generate the images? Which JChem version did you use?


Istvan