hi,
I would recommend using the method:
renderer.paintMolecule(this.mol, (Graphics2D)g, this.getBounds());
as the Java2DRenderer needs to know what size the canvas is (actually,
only the first time it paints, but no matter).
I couldn't get the lines after 323 to work properly, so I used this instead:
IteratingMDLReader reader = new IteratingMDLReader(new
FileReader(input), DefaultChemObjectBuilder.getInstance());
while (reader.hasNext()) {
StructureDiagramGenerator sdg = new StructureDiagramGenerator();
sdg.setMolecule((IMolecule)reader.next());
sdg.generateCoordinates();
v.add((Object)sdg.getMolecule());
}
which works for sdf files, anyway. It may not be the ideal way to do
it, but anyway.
gilleain torrance
On Wed, Apr 29, 2009 at 5:54 PM, Beesley, Angela
<[email protected]> wrote:
> Dear Rajarshi:
>
> Thanks for your prompt reply to my previous question, I managed to
> calculate AlogP correctly and to run the DescriptorEngine fine. As I
> said I am starting with cdk and with java in general, hence my
> struggling. I was trying to compile and run the example that you have in
> your web page regarding tabular display of 2D structures, I downloaded
> the jgrapht library and it is in my classpath. I also have the
> StructureDiagramGenerator class. However there are a few things that I
> don't understand from the program, here are the questions:
>
> 1. The program requires to import
> org.openscience.cdk.renderer.Renderer2D, I don't seem to have this but
> instead I have "org.penscience.cdk.renderer.Java2DRenderer" is this the
> same?
> 2. If so, I need to change line 121 to "Java2Drender renderer;" and line
> 130 to "renderer=new Java2DRenderer;", don't I?
> 3. On line 123 it appears "getAtomAt(i)", is this "getAtom(i)"?
> 4. On line 170 it appears:
>
> renderer.paintMolecule(this.mol,(Graphics2D)g,true); ... this shows an
> error, can I change it to:
> renderer.paintMolecule(this.mol,(Graphics2D)g); ...this seems to be ok.
>
> 5. On line 292, where st2d is declared, the error message shows "class
> st2d is public should be declared in a file name st2d.java". Do I need
> to download st2d.java?
> 6. Problems on line 321 and 322. It appears:
>
> IAtomContainer [] c = ChemFileManipulator......., this generates and
> error, can I chage it to:
> List<IAtomContainer> c = ChemFileManipulator......, this seems to be ok.
>
> Sorry if these questions are too basic! I am picking up more and more
> everyday.
>
> Cheers,
>
> Angela
>
>
>
> -----Original Message-----
> From: [email protected]
> [mailto:[email protected]] On Behalf Of
> [email protected]
> Sent: Wednesday, April 29, 2009 1:02 PM
> To: [email protected]
> Subject: Cdk-user Digest, Vol 35, Issue 15
>
> Send Cdk-user mailing list submissions to
> [email protected]
>
> To subscribe or unsubscribe via the World Wide Web, visit
> https://lists.sourceforge.net/lists/listinfo/cdk-user
> or, via email, send a message with subject or body 'help' to
> [email protected]
>
> You can reach the person managing the list at
> [email protected]
>
> When replying, please edit your Subject line so it is more specific than
> "Re: Contents of Cdk-user digest..."
>
>
> Today's Topics:
>
> 1. Re: Question on descriptors (Rajarshi Guha)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Tue, 28 Apr 2009 09:26:33 -0400
> From: Rajarshi Guha <[email protected]>
> Subject: Re: [Cdk-user] Question on descriptors
> To: "Beesley, Angela" <[email protected]>
> Cc: [email protected]
> Message-ID: <[email protected]>
> Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes
>
>
> On Apr 27, 2009, at 12:25 PM, Beesley, Angela wrote:
>
>> Hi,
>>
>> I am very new on cdk and on java in general so I am struggling a bit
>> with the syntaxis and construction of commands. I managed to read a
>> .sdf file and calculate smiles, now I am trying to calculate AlogP
>> values, however all values return 0.0, I think that I have a problem
>> with explicit hydrogens.
>
> The descriptor will add explicit H's
>
>> This is what i've done:
>>
>> IChemObjectBuilder builder =
>> NoNotificationChemObjectBuilder.getInstance();
>> IMolecule molecule = builder.newMolecule();
>> molecule.addAtom(builder.newAtom("C"));
>> molecule.addAtom(builder.newAtom("C"));
>> molecule.addAtom(builder.newAtom("O"));
>> molecule.addAtom(builder.newAtom("C"));
>
> You don't seem to be adding any bonds between these atoms and hence the
> atom typing will not be correct
>
>> CDKAtomTypeMatcher matcher =
>> CDKAtomTypeMatcher.getInstance(molecule.getBuilder());
>> for (IAtom atom : molecule.atoms()) {
>> IAtomType type = matcher.findMatchingAtomType(molecule, atom);
>> AtomTypeManipulator.configure(atom, type); }
>
> Consider using
> AtomContainerManipulator.perceiveAtomTypesAndConfigureAtoms to do it all
> at one go
>
>> Also, on using the calculation of Individual Descriptors I have no
>> problems (except the AlogP) but when using DescriptorEngine how can I
>> get the numerical values of each descriptor?, so far I have used:
>
> If you're not adding the bonds, I wonder about the validity of those
> descriptor values
>
>> DescriptorEngine engine = new
>> DescriptorEngine(DescriptorEngine.MOLECULAR);
>> engine.process(molecule);
>> but from then I don't know how to get each descriptor separately with
>> their corresponding names.
>
> For a given decsriptor get its DescriptorSpecification object and then
> use that as the key in the getProperty method of IAtomContainer. You can
> get the list of available specification objects via
> DescriptorEngine.getDescriptorSpecifications()
>
> -------------------------------------------------------------------
> Rajarshi Guha <[email protected]>
> GPG Fingerprint: D070 5427 CC5B 7938 929C DD13 66A1 922C 51E7 9E84
> -------------------------------------------------------------------
> Q: What's polite and works for the phone company?
> A: A deferential operator.
>
>
>
>
>
> ------------------------------
>
> ------------------------------------------------------------------------
> ------
> Register Now & Save for Velocity, the Web Performance & Operations
> Conference from O'Reilly Media. Velocity features a full day of
> expert-led, hands-on workshops and two days of sessions from industry
> leaders in dedicated Performance & Operations tracks. Use code vel09scf
> and Save an extra 15% before 5/3. http://p.sf.net/sfu/velocityconf
>
> ------------------------------
>
> _______________________________________________
> Cdk-user mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/cdk-user
>
>
> End of Cdk-user Digest, Vol 35, Issue 15
> ****************************************
>
> ------------------------------------------------------------------------------
> Register Now & Save for Velocity, the Web Performance & Operations
> Conference from O'Reilly Media. Velocity features a full day of
> expert-led, hands-on workshops and two days of sessions from industry
> leaders in dedicated Performance & Operations tracks. Use code vel09scf
> and Save an extra 15% before 5/3. http://p.sf.net/sfu/velocityconf
> _______________________________________________
> Cdk-user mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/cdk-user
>
------------------------------------------------------------------------------
Register Now & Save for Velocity, the Web Performance & Operations
Conference from O'Reilly Media. Velocity features a full day of
expert-led, hands-on workshops and two days of sessions from industry
leaders in dedicated Performance & Operations tracks. Use code vel09scf
and Save an extra 15% before 5/3. http://p.sf.net/sfu/velocityconf
_______________________________________________
Cdk-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/cdk-user