Hi all,

I like to hear comments on this email from Sergey.

Interesting... I have never used the compare() methods... the current
implementation says a bond is the same if it contains the same IAtom
*objects*.

But I do not know why this implementation is like this... ideas?

In addition to the uses which return false below, I think this will return true:

  IAtom atom1 = new Atom("C");
  IAtom atom2 = new Atom("C");
  IBond bond1 = new Bond(atom1, atom2, IBond.Order.SINGLE);
  IBond bond2 = new Bond(atom1, atom2, IBond.Order.SINGLE);
  System.out.println(bond1.compare(bond2));

If not mistaken, that will return true...

Comments please...

Egon

---------- Forwarded message ----------
From: Сергей Соснин <[email protected]>
Date: 2011/10/4
Subject: [cdk-bugs] Bonds comparison trouble
To: [email protected]


Hi,
I have faced that bonds comparison works some unexpected.

For example this code:

       IBond bond1 = new Bond(new Atom("C"), new Atom("C"),
IBond.Order.SINGLE);
       IBond bond2 = new Bond(new Atom("C"), new Atom("C"),
IBond.Order.SINGLE);
       System.out.println(bond1.compare(bond2));

returns false

moreover

      IBond bond1 = new Bond(new Atom("C"), new Atom("C"),
IBond.Order.SINGLE);
      IBond bond2 = (IBond)bond1.clone();
      System.out.println(bond1.compare(bond2));

also returns false

well, it's not that one expect

Method “compare” is ok but it uses “contains” one, so i think that root
of this trouble is here (code from Bond.java)

 public boolean contains(IAtom atom) {
       if (atoms == null) return false;
       for (IAtom localAtom : atoms) {
           if (localAtom == atom) return true; // !!!
       }
       return false;
}
This method will return true only if atom and localAtom are the same
only, not equal.
I think true way is to use atom.compare(localAtom);
Is it a bug?
CDK version is 1.4.4

--
Serg

------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure contains a
definitive record of customers, application performance, security
threats, fraudulent activity and more. Splunk takes this data and makes
sense of it. Business sense. IT sense. Common sense.
http://p.sf.net/sfu/splunk-d2dcopy1
_______________________________________________
Cdk-bugs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/cdk-bugs



-- 
Dr E.L. Willighagen
Postdoctoral Researcher
Institutet för miljömedicin
Karolinska Institutet (http://ki.se/imm)
Homepage: http://egonw.github.com/
LinkedIn: http://se.linkedin.com/in/egonw
Blog: http://chem-bla-ics.blogspot.com/
PubList: http://www.citeulike.org/user/egonw/tag/papers

------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure 
contains a definitive record of customers, application performance, 
security threats, fraudulent activity, and more. Splunk takes this 
data and makes sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-novd2d
_______________________________________________
Cdk-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/cdk-user

Reply via email to