Result of SubStructure Search

User a706ad2bed

01-04-2010 14:42:35

When I use the HitAlignmentAndColoringExample  to do substructure search, the result is confused. When I put the result into Marvin and display it in a frame, the display of the result is correct. But when I  export the result in JPEG format, the hit coloring is incorrect. Just like the picture under.

ChemAxon 42004978e8

02-04-2010 08:18:58

Hi,


How did you export the structure? You can open the structure in MarvinView2D (right click) and then save to an image. I could export a correct image.


 


Bye,


Robert

ChemAxon 9c0afc9aaf

02-04-2010 17:32:58

Hi,


 


We could reproduce the problem, and investigating it.


We will get back to you here soon.


 


Best regards,


 


Szilard

User a706ad2bed

03-04-2010 14:58:37










rwagner wrote:

Hi,


How did you export the structure? You can open the structure in MarvinView2D (right click) and then save to an image. I could export a correct image.


 


Bye,


Robert



I use the method toBinFormat to get the byte array of the image.

User a706ad2bed

12-04-2010 01:56:40

I'd really appreciate if anyone could help me.

ChemAxon 7c2d26e5cf

12-04-2010 14:13:07

To paint molecule with atom/bond sets, you have to specify the setcolors option by image export.


See the documentation of the image export.


byte[] bytes=result.toBinFormat("jpeg:setcolors");

User a706ad2bed

13-04-2010 01:52:05










Tamas wrote:

To paint molecule with atom/bond sets, you have to specify the setcolors option by image export.


See the documentation of the image export.


byte[] bytes=result.toBinFormat("jpeg:setcolors");


Thank you very much for your reply.  I have already set the image export options but unfortunately the result is incorrect. Thanks again for your suggestion

ChemAxon 9c0afc9aaf

14-04-2010 03:27:52

Hi,


For me "jpeg:setcolors" seems to work fine with both 5.2.x and 5.3.x versions.


(the example source will also be updated from the next release accordingly)


Could you double check ?


I the problem persists, please let us know


- your exact JChem version 


- the exact format string (+code to export) you are using 


- in what way the result is "incorrect" ? (please also attach the query and target as structure files)


 


Best regards,


 


Szilard

User a706ad2bed

15-04-2010 01:28:26










Szilard wrote:

Hi,


For me "jpeg:setcolors" seems to work fine with both 5.2.x and 5.3.x versions.


(the example source will also be updated from the next release accordingly)


Could you double check ?


I the problem persists, please let us know


- your exact JChem version 


- the exact format string (+code to export) you are using 


- in what way the result is "incorrect" ? (please also attach the query and target as structure files)


 


Best regards,


 


Szilard



My JChem version is 5.3.1.


My code is


public class HitAlignmentAndColoringExample {
   
    /**
     * Reads the first strcucture from a file.
     * @param fileName the name of the file
     */
    static Molecule readFromFile(String fileName) throws Exception {
        MolInputStream mis=null;
        try {
            mis = new MolInputStream(new FileInputStream(fileName));
        } catch (FileNotFoundException e) {
            throw new Exception("File not found:"+fileName);
        }
        MolImporter molimp = new MolImporter(mis);
        Molecule mol=molimp.read();
        mis.close();
        return mol;
    }
   
    /**
     * Command-line entry point
     * @param args the command line arguments
     */
    public static void main(String[] args) throws Exception {
        if (args.length!=2) {
            System.err.println("usage: <query_file> <target_File>");
            return; //exits
        }


        //reading structures from file:
        Molecule query=readFromFile(args[0]);
        Molecule target=readFromFile(args[1]);
       
       
        HitColoringAndAlignmentOptions options =
                new HitColoringAndAlignmentOptions();
        options.coloring = true;
        options.alignmentMode = HitColoringAndAlignmentOptions.ALIGNMENT_OFF;
        options.hitColor = Color.RED;
        options.nonHitColor = Color.BLACK;
       
        MolSearchOptions mso = new MolSearchOptions();
        HitDisplayTool hdt = new HitDisplayTool(options, mso, null, query);
        Molecule result = hdt.getHit(target);
       
       
        if (result == null) {
            System.err.println("Substructure not found");
            return; //exits
        }


        MViewPane mpan=new MViewPane();
       
        //Uncomment this section to export in JPEG format (preserves hit coloring):
        /*byte[] bytes=result.toBinFormat("jpeg");
        FileOutputStream fos=new FileOutputStream("out.jpeg");
        fos.write(bytes);
        fos.close();*/


        //putting the structure into Marvin:
        mpan.setM(0, result);
        //displaying the result in a frame:
        JFrame frame=new JFrame();
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.getContentPane().add(mpan);
        frame.pack();
        frame.setSize(300,300);
        frame.setVisible(true);
    }
   
}


When I use the JFrame, the result is correct. But when output as a JPEG image, the result is incorrect.  

ChemAxon 9c0afc9aaf

15-04-2010 04:19:23




Hi,


The code you have pasted


1.  does not produce any image file output at all (that part is commented out)


2.  Even if you uncomment this section, you still have :


result.toBinFormat("jpeg");


instead of


result.toBinFormat("jpeg:setcolors");


as recommended by Tamas to enable atom/bond set colors..


After these 2 necessary changes the code produces an image output for your structures with JChem 5.3.1 that looks OK for us. (attached)


Please describe in detail if something you think is incorrect with this result.


 


Thanks,


Szilard 


 



 

User a706ad2bed

15-04-2010 04:39:32










Szilard wrote:

 



Hi,


The code you have pasted


1.  does not produce any image file output at all (that part is commented out)


2.  Even if you uncomment this section, you still have :


result.toBinFormat("jpeg");


instead of


result.toBinFormat("jpeg:setcolors");


as recommended by Tamas to enable atom/bond set colors..


After these 2 necessary changes the code produces an image output for your structures with JChem 5.3.1 that looks OK for us. (attached)


Please describe in detail if something you think is incorrect with this result.


 


Thanks,


Szilard 


 



 



Thank you very much.


I used these codes:


public class HitAlignmentAndColoringExample2 {


 /**
  * Reads the first strcucture from a file.
  *
  * @param fileName
  *            the name of the file
  */
 static Molecule readFromFile(String fileName) throws Exception {
  MolInputStream mis = null;
  try {
   mis = new MolInputStream(new FileInputStream(fileName));
  } catch (FileNotFoundException e) {
   throw new Exception("File not found:" + fileName);
  }
  MolImporter molimp = new MolImporter(mis);
  Molecule mol = molimp.read();
  mis.close();
  return mol;
 }


 /**
  * Command-line entry point
  *
  * @param args
  *            the command line arguments
  */
 public static void main(String[] args) throws Exception {
  if (args.length != 2) {
   System.err.println("usage: <query_file> <target_File>");
   return; // exits
  }


  // reading structures from file:
  Molecule query = readFromFile(args[0]);
  Molecule target = readFromFile(args[1]);


  HitColoringAndAlignmentOptions options = new HitColoringAndAlignmentOptions();
  options.coloring = true;
  options.alignmentMode = HitColoringAndAlignmentOptions.ALIGNMENT_OFF;
  options.hitColor = Color.RED;
  options.nonHitColor = Color.BLACK;


  MolSearchOptions mso = new MolSearchOptions();
  HitDisplayTool hdt = new HitDisplayTool(options, mso, null, query);
  Molecule result = hdt.getHit(target);


  if (result == null) {
   System.err.println("Substructure not found");
   return; // exits
  }
  byte[] bytes = result.toBinFormat("jpeg");
  FileOutputStream fos = new FileOutputStream("E:\\out.jpeg");
  fos.write(bytes);
  fos.close();


 }


}


Do you think there is anything wrong?  I can't get the correct image.

ChemAxon a3d59b832c

15-04-2010 06:41:38

Please use this call to create the image:


result.toBinFormat("jpeg:setcolors");


That should help.


Best regards,


Szabolcs

User a706ad2bed

15-04-2010 07:07:06










Szabolcs wrote:

Please use this call to create the image:


result.toBinFormat("jpeg:setcolors");


That should help.


Best regards,


Szabolcs



Thank you very much indeed