I tried with atom assignment ant aromaticity check also but not able to get
correct output.
I am providing my code with this mail please help me out.
Thanks in advance!
package newpackage;
import java.awt.Component;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JFileChooser;
import javax.swing.JOptionPane;
import javax.swing.JTable;
import javax.swing.filechooser.FileFilter;
import javax.swing.filechooser.FileNameExtensionFilter;
import javax.swing.table.DefaultTableModel;
import org.openscience.cdk.io.iterator.IteratingSDFReader;
import org.openscience.cdk.DefaultChemObjectBuilder;
import org.openscience.cdk.interfaces.IAtomContainer;
import org.openscience.cdk.qsar.result.DoubleResult;
import org.openscience.cdk.qsar.descriptors.molecular.WeightDescriptor;
import org.openscience.cdk.CDKConstants;
import org.openscience.cdk.exception.CDKException;
import org.openscience.cdk.qsar.descriptors.molecular.XLogPDescriptor;
import org.openscience.cdk.qsar.result.DoubleArrayResult;
import org.openscience.cdk.qsar.descriptors.molecular.ALOGPDescriptor;
import org.openscience.cdk.qsar.result.IntegerResult;
import
org.openscience.cdk.qsar.descriptors.molecular.HBondAcceptorCountDescriptor;
import
org.openscience.cdk.qsar.descriptors.molecular.HBondDonorCountDescriptor;
import
org.openscience.cdk.qsar.descriptors.molecular.RotatableBondsCountDescriptor;
import org.openscience.cdk.qsar.descriptors.molecular.AtomCountDescriptor;
import org.openscience.cdk.ringsearch.SSSRFinder;
import org.openscience.cdk.interfaces.IRingSet;
import org.openscience.cdk.qsar.descriptors.molecular.BondCountDescriptor;
import org.openscience.cdk.qsar.descriptors.molecular.TPSADescriptor;
import java.awt.Color;
import java.io.BufferedWriter;
import java.io.FileWriter;
import javax.swing.table.TableCellRenderer;
import org.openscience.cdk.aromaticity.Aromaticity;
import org.openscience.cdk.aromaticity.ElectronDonation;
import org.openscience.cdk.graph.Cycles;
import org.openscience.cdk.io.SDFWriter;
import org.openscience.cdk.tools.manipulator.AtomContainerManipulator;
public class NewJFrame extends javax.swing.JFrame {
public NewJFrame() {
initComponents();
}
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
openfile = new javax.swing.JFileChooser();
savefile2 = new javax.swing.JFileChooser();
jTabbedPane1 = new javax.swing.JTabbedPane();
jScrollPane2 = new javax.swing.JScrollPane();
jTable1 = new javax.swing.JTable();
jPanel1 = new javax.swing.JPanel();
Browse = new javax.swing.JButton();
jScrollPane1 = new javax.swing.JScrollPane();
tb1 = new javax.swing.JTextPane();
Cal_prop = new javax.swing.JButton();
jLabel1 = new javax.swing.JLabel();
progressBar1 = new javax.swing.JProgressBar();
jMenuBar1 = new javax.swing.JMenuBar();
jMenu1 = new javax.swing.JMenu();
jMenuItem1 = new javax.swing.JMenuItem();
jMenu2 = new javax.swing.JMenu();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setTitle("Drug Dendrimer Compatibility Checker");
jTable1.setModel(new javax.swing.table.DefaultTableModel(
new Object [][] {
{null, null, null, null, null, null, null, null, null,
null, null, null, null, null, null},
{null, null, null, null, null, null, null, null, null,
null, null, null, null, null, null},
{null, null, null, null, null, null, null, null, null,
null, null, null, null, null, null},
{null, null, null, null, null, null, null, null, null,
null, null, null, null, null, null}
},
new String [] {
"S. No", "Title", "MW", "logP", "AlogP", "HBA", "HBD",
"TPSA", "AMR", "nRB", "nAtom", "RC", "nRigidB", "nHB", "SAlerts"
}
));
jScrollPane2.setViewportView(jTable1);
jTabbedPane1.addTab("Drug Properties", jScrollPane2);
Browse.setText("Browse");
Browse.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
BrowseActionPerformed(evt);
}
});
jScrollPane1.setViewportView(tb1);
Cal_prop.setText("calculate_properties");
Cal_prop.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
Cal_propActionPerformed(evt);
}
});
progressBar1.setCursor(new
java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
javax.swing.GroupLayout jPanel1Layout = new
javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(21, 21, 21)
.addComponent(jScrollPane1,
javax.swing.GroupLayout.PREFERRED_SIZE, 234,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(31, 31, 31)
.addComponent(Browse,
javax.swing.GroupLayout.PREFERRED_SIZE, 75,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(30, 30, 30)
.addComponent(Cal_prop)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 25,
Short.MAX_VALUE)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(progressBar1,
javax.swing.GroupLayout.PREFERRED_SIZE, 285,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(10, 10, 10)
.addComponent(jLabel1,
javax.swing.GroupLayout.PREFERRED_SIZE, 232,
javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGap(31, 31, 31))
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
jPanel1Layout.createSequentialGroup()
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING,
false)
.addComponent(jScrollPane1)
.addComponent(Browse,
javax.swing.GroupLayout.DEFAULT_SIZE, 38, Short.MAX_VALUE)
.addComponent(Cal_prop,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE))
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(progressBar1,
javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel1,
javax.swing.GroupLayout.PREFERRED_SIZE, 20,
javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGap(170, 170, 170))
);
jMenu1.setText("File");
jMenuItem1.setText("jMenuItem1");
jMenuItem1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem1ActionPerformed(evt);
}
});
jMenu1.add(jMenuItem1);
jMenuBar1.add(jMenu1);
jMenu2.setText("Edit");
jMenuBar1.add(jMenu2);
setJMenuBar(jMenuBar1);
javax.swing.GroupLayout layout = new
javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jTabbedPane1)
.addGroup(layout.createSequentialGroup()
.addComponent(jPanel1,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
Short.MAX_VALUE)
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jTabbedPane1,
javax.swing.GroupLayout.PREFERRED_SIZE, 121,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jPanel1,
javax.swing.GroupLayout.PREFERRED_SIZE, 100,
javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(263, Short.MAX_VALUE))
);
pack();
}// </editor-fold>
public Color getTableCellBackground(JTable table, int row, int col) {
TableCellRenderer renderer = table.getCellRenderer(row, col);
Component component = table.prepareRenderer(renderer, row, col);
return component.getBackground();
}
private void BrowseActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
FileFilter ft = new FileNameExtensionFilter("Sdf file (.sdf)",
"sdf");
FileFilter ft2 = new FileNameExtensionFilter("Mol file (.mol)",
"mol");
openfile.setAcceptAllFileFilterUsed(false);
if (openfile.getFileFilter() == null)
{
openfile.addChoosableFileFilter(ft);
openfile.addChoosableFileFilter(ft2);
}
int returnVal = openfile.showOpenDialog(jMenu1);
if(returnVal == JFileChooser.APPROVE_OPTION)
{
tb1.setText(openfile.getSelectedFile().toString());
}
}
private void Cal_propActionPerformed(java.awt.event.ActionEvent evt) {
if ("".equals(tb1.getText()))
{
JOptionPane.showMessageDialog(null, "Please give a valid input
file");
}
else
{
Cal_prop.setEnabled(false);
((DefaultTableModel )jTable1.getModel()).setRowCount(0);
progressBar1.setValue(0);
progressBar1.setBackground(Color.GREEN);
progressBar1.setForeground(Color.GREEN);
progressBar1.setEnabled(true);
new LongRunningOperation().start();
}
}
private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt)
{
// TODO add your handling code here:
IAtomContainer imol;
int d =0;
FileFilter ft = new FileNameExtensionFilter("sdf file
(.sdf)", "sdf");
savefile2.setAcceptAllFileFilterUsed(false);
if (savefile2.getFileFilter() == null)
{
savefile2.addChoosableFileFilter(ft);
}
int returnVal = savefile2.showOpenDialog(jMenu1);
if(returnVal == JFileChooser.APPROVE_OPTION)
{
FileWriter fstream;
try {
fstream = new
FileWriter(savefile2.getSelectedFile()+".sdf");
BufferedWriter out = new BufferedWriter(
fstream);
FileReader filereader2 = new
FileReader(tb1.getText());
IteratingSDFReader mdlreader = new
IteratingSDFReader(filereader2, DefaultChemObjectBuilder.getInstance());
SDFWriter sdfwriter = new
SDFWriter(out);
while (mdlreader.hasNext())
{
imol =
(IAtomContainer)mdlreader.next();
if
(getTableCellBackground(jTable1 , d , 0)== Color.green)
{ try {
sdfwriter.write(imol);
d++;
} catch (Exception ex) {
Logger.getLogger(NewJFrame.class.getName()).log(Level.SEVERE, null, ex);
}
AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(imol);
Aromaticity aromaticity = new
Aromaticity(ElectronDonation.daylight(),
Cycles.vertexShort());
aromaticity.apply(imol);
}
else
{
d++;
}
}
out.close();
}
catch (IOException ex)
{
Logger.getLogger(NewJFrame.class.getName()).log(Level.SEVERE, null, ex);
} catch (CDKException ex) {
Logger.getLogger(NewJFrame.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
class LongRunningOperation extends Thread {
@Override
public void run()
{
try {
double MolecularWeight, logPVal, tpsaVal, alogp, amr;
String name;
int i = 0, j = 0, acceptor, donor, nrotatblebond,
natomcount, nacidic, ring, bondcount, rigidbondcount, totalmatch = 0;
IteratingSDFReader mdlreader;
IAtomContainer mol;
DoubleResult dr;
IntegerResult ir;
DoubleArrayResult dar;
WeightDescriptor weight;
weight = new WeightDescriptor();
XLogPDescriptor logP = new XLogPDescriptor();
ALOGPDescriptor alogP = new ALOGPDescriptor();
HBondAcceptorCountDescriptor hba = new
HBondAcceptorCountDescriptor();
HBondDonorCountDescriptor hbd = new
HBondDonorCountDescriptor();
RotatableBondsCountDescriptor nrb = new
RotatableBondsCountDescriptor();
AtomCountDescriptor ac = new AtomCountDescriptor();
BondCountDescriptor bc = new BondCountDescriptor();
TPSADescriptor tpsa = new TPSADescriptor();
FileReader filereader1 = new FileReader(tb1.getText());
IteratingSDFReader molReader1 = new
IteratingSDFReader(filereader1, DefaultChemObjectBuilder.getInstance());
int nmolecule = 0;
while (molReader1.hasNext())
{
molReader1.next();
nmolecule++;
}
try {
molReader1.close();
} catch (IOException ex) {
Logger.getLogger(NewJFrame.class.getName()).log(Level.SEVERE, null, ex);
}
FileReader filereader2 = new FileReader(tb1.getText());
mdlreader = new IteratingSDFReader(filereader2,
DefaultChemObjectBuilder.getInstance());
while (mdlreader.hasNext())
{
i = i+1;
totalmatch = 0;
mol = (IAtomContainer)mdlreader.next();
dr = (DoubleResult)weight.calculate(mol).getValue();
MolecularWeight = dr.doubleValue();
dr = (DoubleResult)logP.calculate(mol).getValue();
logPVal = dr.doubleValue();
dar = (DoubleArrayResult)alogP.calculate(mol).getValue();
alogp = dar.get(0);
amr = dar.get(2);
ir = (IntegerResult)hba.calculate(mol).getValue();
acceptor = ir.intValue();
ir = (IntegerResult)hbd.calculate(mol).getValue();
donor = ir.intValue();
dr = (DoubleResult)tpsa.calculate(mol).getValue();
tpsaVal = dr.doubleValue();
ir = (IntegerResult)nrb.calculate(mol).getValue();
nrotatblebond = ir.intValue();
ir = (IntegerResult)ac.calculate(mol).getValue();
natomcount = ir.intValue();
SSSRFinder rc = new SSSRFinder(mol);
IRingSet trial;
trial = rc.findSSSR();
ring = trial.getAtomContainerCount();
ir = (IntegerResult)bc.calculate(mol).getValue();
bondcount = ir.intValue();
rigidbondcount = bondcount - nrotatblebond;
// Do the configuration
try {
AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(mol);
} catch (CDKException e) {
throw new CDKException("Error in atom typing" + e.toString());
}
// do a aromaticity check
try {
Aromaticity aromaticity = new
Aromaticity(ElectronDonation.daylight(),
Cycles.vertexShort());
aromaticity.apply(mol);
} catch (CDKException e) {
throw new CDKException("Error in aromaticity detection");
}
name = (String)mol.getProperty(CDKConstants.TITLE);
//output to grid of calculated molecular properties
((DefaultTableModel )jTable1.getModel()).addRow(new
Object[]{i, name, (Math.round(MolecularWeight *
100.0)/100.0),(Math.round(logPVal * 1000.0)/1000.0), (Math.round(alogp *
1000.0)/1000.0), acceptor, donor, (Math.round(tpsaVal * 100.0)/100.0),
(Math.round(amr * 100.0)/100.0), nrotatblebond, natomcount,ring,
rigidbondcount, (acceptor+donor), totalmatch });
progressBar1.setValue((i*100)/nmolecule);
jLabel1.setText("Molecules completed" + "(" + i + ")");
}
} catch (CDKException | FileNotFoundException ex) {
Logger.getLogger(NewJFrame.class.getName()).log(Level.SEVERE, null, ex);
}
done();
}
public void done()
{
JOptionPane.showMessageDialog(null,"Molecular properties
calculation is completed");
Cal_prop.setEnabled(true);
}
}
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new NewJFrame().setVisible(true);
}
});
}
// Variables declaration - do not modify
javax.swing.JButton Browse;
javax.swing.JButton Cal_prop;
javax.swing.JLabel jLabel1;
javax.swing.JMenu jMenu1;
javax.swing.JMenu jMenu2;
javax.swing.JMenuBar jMenuBar1;
javax.swing.JMenuItem jMenuItem1;
javax.swing.JPanel jPanel1;
javax.swing.JScrollPane jScrollPane1;
private javax.swing.JScrollPane jScrollPane2;
javax.swing.JTabbedPane jTabbedPane1;
private javax.swing.JTable jTable1;
javax.swing.JFileChooser openfile;
javax.swing.JProgressBar progressBar1;
javax.swing.JFileChooser savefile2;
javax.swing.JTextPane tb1;
// End of variables declaration
}
Rahul Singh Gurjar
M.S. (Pharm),
Department Of Pharmacoinformatics,
NIPER, S.A.S. Nagar, Mohali,
Punjab, India.
Mail ID : singhgurjarra...@gmail.com
Contact : +91 7814192659
On Tue, May 12, 2015 at 5:40 PM, Rajarshi Guha <rajarshi.g...@gmail.com>
wrote:
> yes
>
> On Tue, May 12, 2015 at 8:03 AM, rahul singh gurjar <
> singhgurjarra...@gmail.com> wrote:
>
>> No it is not assigned in my code, does it needed for descriptor
>> calculation.
>>
>> Rahul Singh Gurjar
>> M.S. (Pharm),
>> Department Of Pharmacoinformatics,
>> NIPER, S.A.S. Nagar, Mohali,
>> Punjab, India.
>>
>> Mail ID : singhgurjarra...@gmail.com
>>
>> Contact : +91 7814192659
>>
>> On Tue, May 12, 2015 at 5:11 PM, Rajarshi Guha <rajarshi.g...@gmail.com>
>> wrote:
>>
>>> does your code assign atom types and aromaticity? See line 169 onwards
>>> in
>>> https://github.com/rajarshi/cdkdescui/blob/master/src/main/java/net/guha/apps/cdkdesc/DescriptorSwingWorker.java
>>>
>>> On Tue, May 12, 2015 at 7:37 AM, rahul singh gurjar <
>>> singhgurjarra...@gmail.com> wrote:
>>>
>>>> Now I am using CDK 1.5.10, even though I am getting the same output for
>>>> the XlogP.
>>>> I don't think so John that version is problem, because I am getting
>>>> similar output for XlogP calculation with all the versions.
>>>> But when I am calculating same descriptor with CDK Descriptor
>>>> Calculator GUI output is different.
>>>>
>>>>
>>>> Rahul Singh Gurjar
>>>> M.S. (Pharm),
>>>> Department Of Pharmacoinformatics,
>>>> NIPER, S.A.S. Nagar, Mohali,
>>>> Punjab, India.
>>>>
>>>> Mail ID : singhgurjarra...@gmail.com
>>>>
>>>> Contact : +91 7814192659
>>>>
>>>> On Tue, May 12, 2015 at 4:36 PM, John M <john.wilkinson...@gmail.com>
>>>> wrote:
>>>>
>>>>>
>>>>> Ah right, yes Rahul the latest version for CDK is 1.5.10 (use Maven
>>>>> central).
>>>>>
>>>>> J
>>>>>
>>>>
>>>>
>>>>
>>>> ------------------------------------------------------------------------------
>>>> One dashboard for servers and applications across Physical-Virtual-Cloud
>>>> Widest out-of-the-box monitoring support with 50+ applications
>>>> Performance metrics, stats and reports that give you Actionable Insights
>>>> Deep dive visibility with transaction tracing using APM Insight.
>>>> http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
>>>> _______________________________________________
>>>> Cdk-user mailing list
>>>> Cdk-user@lists.sourceforge.net
>>>> https://lists.sourceforge.net/lists/listinfo/cdk-user
>>>>
>>>>
>>>
>>>
>>> --
>>> Rajarshi Guha | http://blog.rguha.net
>>> NIH Center for Advancing Translational Science
>>>
>>
>>
>
>
> --
> Rajarshi Guha | http://blog.rguha.net
> NIH Center for Advancing Translational Science
>
------------------------------------------------------------------------------
One dashboard for servers and applications across Physical-Virtual-Cloud
Widest out-of-the-box monitoring support with 50+ applications
Performance metrics, stats and reports that give you Actionable Insights
Deep dive visibility with transaction tracing using APM Insight.
http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
_______________________________________________
Cdk-user mailing list
Cdk-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/cdk-user