mcs
User 031cf6afbd
23-11-2007 17:32:25
Dear Sirs,
i have to perform a MCS on two molecules and get the atom indices of the query that matches my following code throws a nullpointerexeption because the results are null:
MCS s2= new MCS();
s2.setMolecules(query,target);
s2.setQuery(query);
s2.setTarget(target);
s2.setMCSMode(true);
s2.search();
int results[]=s2.getResult();
is there a bug and how do i interpret the results array?
plz help me .
User 031cf6afbd
23-11-2007 17:36:35
sorry this is the hole code:
bufferedInputStream tis1=null;
tis1 = new BufferedInputStream(
new FileInputStream("referenceMolecule.sdf"));
MolInputStream tmis1 = new MolInputStream(tis1);
MolImporter tmolimp1 = new MolImporter(tmis1);
Molecule query = tmolimp1.read();
// use Molfile molecule as target
BufferedInputStream tis=null;
tis = new BufferedInputStream(
new FileInputStream("reconstructedMolecule.sdf"));
MolInputStream tmis = new MolInputStream(tis);
MolImporter tmolimp = new MolImporter(tmis);
Molecule target = tmolimp.read();
MCS s2= new MCS();
s2.setMolecules(query,target);
s2.setQuery(query);
s2.setTarget(target);
s2.setMCSMode(true);
s2.search();
int results[]=s2.getResult();
if(results==null){
// setting the matchesReference flag for every not matching atom
for(int i=0;i<=s2.getResultSize();i++){
System.out.println(results);
}
ChemAxon efa1591b5a
26-11-2007 09:23:39
Hi,
try a somewhat modified code, sg. like:
Code: |
if ( s2.search() ) {
int results[]=s2.getResult();
.
.
}
|
Does this help?
Regards,
Miklos
User 031cf6afbd
26-11-2007 13:46:37
Hi mvargyas thanks for the reply,
but search dont work at all here ,it seems that the molecules are not loaded here .
because "s2.search()" returns false.
ChemAxon efa1591b5a
26-11-2007 13:59:03
When search returns false it means that no solution was found, see the API documentation:
http://www.chemaxon.com/jchem/doc/api/chemaxon/sss/search/MCS.html#search().
Does this help?
Try a simple case when the two structure are the same. Do you get an output?
So the code should look sg like this:
Code: |
if ( s2.search() ) {
int results[]=s2.getResult();
.
.
}
else {
System.out.println("No MCS found."); // means that there's no MCS that meets all constraints
}
|
Regards,
Miklos
User 031cf6afbd
27-11-2007 10:05:25
hi mvargyas
thank you very much it is working fine now.
User 031cf6afbd
10-12-2007 14:30:07
Hi,
i have the feeling that the api mcs ist less accurate than the binary mcs ,the results habe big differences.Or i am using the wrong parameters?Does anyone have the same experience.
ChemAxon 9c0afc9aaf
13-12-2007 17:31:05
Hi,
Miklos is abroad for the rest of the week, but let me give you a short answer.
Quote: |
i have the feeling that the api mcs ist less accurate than the binary mcs |
The program uses the very same API, therefore the same algorithm, so this is impossible.
That is, of course, if you are using the same version of the program and the API. You can check the version of a jchem.jar in the following way:
java -jar jchem.jar
Please see this topic for further information:
http://www.chemaxon.com/forum/ftopic127.html
Unfortunately might be a bit harder to determine which jchem version the mcs was released with.
1. Display a structure in the GUI
2. Right-click on it, select Help -> About Marvin
3. Go the the history of JChem changes to check which JChem contains this Marvin version:
http://www.chemaxon.com/jchem/changes.html
We will unify our product versions in the future, and determining the program version will also be more easier. Quote: |
Or i am using the wrong parameters? |
If you are using the same version, then then it must be the way of usage indeed.
If you send us an example (input, source code, result difference) where the difference can be reproduced and you do not understand the reason, Miklos will take a look at your code next week and see if there are obvious problems.
Best regards,
Szilard
User 031cf6afbd
17-12-2007 14:37:06
Hi
my jchem api version has 3.2.11
Table version: 41
my MarvinView is at version 4.0.1 is it the August 23, 2005: 3.1 version then?
my code is the following:
public class mcs {
/**
* @param args
*/
public static void main(String[] args) {
try {
BufferedInputStream tis1=null;
tis1 = new BufferedInputStream(
new FileInputStream("reconstructedMolecule.sdf"));
MolInputStream tmis1 = new MolInputStream(tis1);
MolImporter tmolimp1 = new MolImporter(tmis1);
Molecule target1 = tmolimp1.read();
// use sdfile molecule as target
BufferedInputStream tis=null;
tis = new BufferedInputStream(
new FileInputStream("referenceMolecule.sdf"));
MolInputStream tmis = new MolInputStream(tis);
MolImporter tmolimp = new MolImporter(tmis);
Molecule target = tmolimp.read();
MCS s2= new MCS();
s2.setMolecules(target1,target);
//s2.setMCESMode(true);
s2.setMCSMode(true);
System.out.println(chemaxon.jchem.VersionInfo.JCHEM_VERSION);
System.out.println(chemaxon.jchem.VersionInfo.JCHEM_TABLE_VERSION);
if ( s2.search() ) {
System.out.println("sucht und sucht");
int results[]=s2.getResult();
for(int i=0;i<s2.getResultSize();i++){
System.out.println(results);
}
}
// MolAtom resultAtom[]= s2.getResultTargetAtoms();
// System.out.println(s2.getResultSize());
} catch (IOException e) {
e.printStackTrace();
System.exit(1);
}//end catch
}//end main
}//end searchTest
-------------------
the result is:
[7, 5, 0, 4, 3, 6, 9, -1, 1, 8, -1, -1, -1]
the result from mcs is:
1 -> 8
2 -> 6
3 -> 7
4 -> 1
5 -> 2
6 -> 5
7 -> 4
8 -> 3
9 -> 10
10 -> 9
11 -> 11
12 -> 12
the sdfiles are attached.
thank you very much!
User 031cf6afbd
17-12-2007 17:25:48
Hi ,also when i try to iterate through getResultqueryAtoms
for(MolAtom ma : s2.getResultQueryAtoms()) {
logger.info(ma);
}
i get the following :
java.lang.ArrayIndexOutOfBoundsException: 9
at chemaxon.marvin.modules.CommonStructureSearch.getResultQueryAtoms(CommonStructureSearch.java:664)
at
chemaxon.sss.search.MCS.getResultQueryAtoms(MCS.java:302)
ChemAxon efa1591b5a
18-12-2007 11:49:26
I will check both problems you reported and then get back to this forum to provide detailed and specific response asap.
regards,
Miklos
User 031cf6afbd
21-12-2007 12:56:40
ok i am looking forward to it.
thanks a lot
User 031cf6afbd
14-01-2008 16:17:09
Hi mvargyas
did you have any results ?
my tast kind of depend on this :-)
thanx
ChemAxon efa1591b5a
18-01-2008 09:15:28
Hi there,
apologies for not getting back to you sooner.
Could you check with the recent release version 5.0? I believe the problem has been fixed. It certainly does not crash, and the output of your sample code is:
Quote: |
sucht und sucht
7
5
6
0
1
4
3
2
9
8
10
11
|
However, please note the the API of the MCS class has slightly been changed that also affects your code. In particular, the return type of method getResultQueryAtoms() is int[] (not MolAtom[] any more), see: http://www.chemaxon.com/jchem/doc/api/chemaxon/sss/search/MCS.html#getResultQueryAtoms().
Does this solve your problem?
Regards,
Miklos
User 031cf6afbd
18-01-2008 15:16:09
works like a charm thank you very much :-)
ChemAxon efa1591b5a
18-01-2008 16:15:02
Thanks for your patience! Please report all problems you encounter, also, all suggestions and feature requests are welcome.
Miklos
User 031cf6afbd
21-01-2008 17:27:13
Hi Miklos and Mvargyas
i just noticed that the getRestultQueryBonds() method always returns null
whether there is a result as int[][] from getResult() or not.
Its seems to be a bug.
Greets
msouiai
ChemAxon efa1591b5a
23-01-2008 14:47:59
Hi Msouiai,
indeed, I can confirm that it is a bug. We will fix it in the next minor release (5.0.1, due around 4 February).
Regards,
Miklos
ChemAxon efa1591b5a
24-01-2008 10:42:50
According to the most recent information I got the next bugfix release is scheduled on 13 February.
Miklos
User 76612d09f2
07-02-2008 23:56:12
mvargyas wrote: |
According to the most recent information I got the next bugfix release is scheduled on 13 February.
Miklos |
Please update me
karthik
ChemAxon efa1591b5a
08-02-2008 11:27:25
The bug has been fixed and tested.
The release is still scheduled by Wednesday, 13 February. Alpha release will be build on Monday.
Miklos
ChemAxon 9c0afc9aaf
08-02-2008 11:37:26
User 031cf6afbd
14-02-2008 09:13:11
Hi Szilard,
thanks for the bugfix ,i cant see the release of 5.01 in the download section though.
regards
msouiai
ChemAxon efa1591b5a
14-02-2008 09:23:54
The patch release is not out yet (though it was scheduled for yesterday). We expect it by 1300 hour today.... You'll be notified.
Miklos
ChemAxon efa1591b5a
18-02-2008 08:49:20
Release of jchem was delayed due to a critical bug in marvinsketch.
We will notify you when he stable version is released.
M.
ChemAxon efa1591b5a
19-02-2008 08:00:48
JChem 5.0.1 has been released.
Regards,
Miklos
User 031cf6afbd
21-02-2008 13:14:54
Hi Miklos,
i tried the fixed mcs module now, and there is no nullpointer exeption anymore.
But i got wrong results ,for instance with the example i posted above i got following:
edge between:6and6
edge between:7and6
edge between:6and6
edge between:6and6
edge between:6and6
edge between:6and6
edge between:6and6
edge between:6and6
edge between:6and6
edge between:6and6
edge between:6and8
edge between:6and8
and that cant be :-(
ChemAxon efa1591b5a
25-02-2008 09:13:41
Hm... that's very odd indeed. We'll check it and get back to you soon.
Regards,
Miklos
User 031cf6afbd
26-02-2008 14:44:59
Hi Miklos ,
thanks for your patience with me,i have another quetion ,
is there a possibility to search for the actual mcs not the mces? I want to find also not connected components.
Regards
Msouiai
ChemAxon efa1591b5a
27-02-2008 09:54:14
Hm, this is puzzling: I tried your structures and I got this output:
query bonds:
0 - 1
5 - 0
1 - 2
2 - 3
3 - 4
4 - 5
5 - 6
5 - 7
6 - 9
7 - 8
9 - 10
9 - 11
target bonds:
5 - 6
1 - 5
6 - 7
4 - 7
3 - 4
1 - 3
2 - 1
0 - 1
2 - 8
9 - 0
8 - 10
8 - 11
This looks o.k. though I did not check each and every bond one-by-one just picked some of them...
What do you think?
Thanks
Miklos
User 031cf6afbd
29-02-2008 10:16:51
Hi , this is my code:
import java.io.BufferedInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import chemaxon.formats.MolImporter;
import chemaxon.formats.MolInputStream;
import chemaxon.sss.search.MCS;
import chemaxon.sss.search.SearchException;
import chemaxon.sss.search.StandardizedMolSearch;
import chemaxon.struc.MolAtom;
import chemaxon.struc.MolBond;
import chemaxon.struc.Molecule;
import chemaxon.util.MolHandler;
public class mcs {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
try {
BufferedInputStream tis1=null;
tis1 = new BufferedInputStream(
new FileInputStream("reconstructedMolecule.sdf"));
MolInputStream tmis1 = new MolInputStream(tis1);
MolImporter tmolimp1 = new MolImporter(tmis1);
Molecule target1 = tmolimp1.read();
target1.aromatize();
// use sdfile molecule as target
BufferedInputStream tis=null;
tis = new BufferedInputStream(
new FileInputStream("referenceMolecule.sdf"));
MolInputStream tmis = new MolInputStream(tis);
MolImporter tmolimp = new MolImporter(tmis);
Molecule target = tmolimp.read();
target.aromatize();
MCS s2= new MCS();
s2.setMolecules(target1,target);
//s2.setMCESMode(true);
if ( s2.search() ) {
MolBond[] resultBonds=s2.getResultQueryBonds();
for (int i = 0; i < resultBonds.length; i++) {
System.out.println("bond"+i+":"+resultBonds.getAtom1().getAtno()+"and"+resultBonds.getAtom2().getAtno());
}
}
} catch (IOException e) {
e.printStackTrace();
System.exit(1);
}//end catch
}//end main
}//end searchTest
my result is once again:
bond0:6and6
bond1:7and6
bond2:6and6
bond3:6and6
bond4:6and6
bond5:6and6
bond6:6and6
bond7:6and6
bond8:6and6
bond9:6and6
bond10:6and8
bond11:6and8
what did i do wrong?
greets
msouiai
ChemAxon efa1591b5a
04-03-2008 10:53:52
Hi, I guess you did not do anything wrong. The difference you encountered between my output and yours (and possible between the output you got and the one you expected, supposedly) is due to the fact that you printed atno()-s, that is, atomic numbers, but not actual atom indeces in your molecules. You got many 6-s as you have some Carbon atoms in you structure.
To obtain indeces you need sg like this:
Code: |
if ( mcs.search() ) {
System.out.println( mcs.getResultAsMolecule().toFormat( "smiles"));
System.out.println( "query: " );
MolBond [] qb = mcs.getResultQueryBonds();
for ( int i = 0; i < qb.length; i++ ) {
MolAtom a1 = qb[i].getAtom1();
MolAtom a2 = qb[i].getAtom2();
System.out.println( query.indexOf(a1) + " - " + query.indexOf(a2) );
}
System.out.println( "target: " );
MolBond [] tb = mcs.getResultTargetBonds();
for ( int i = 0; i < tb.length; i++ ) {
MolAtom a1 = tb[i].getAtom1();
MolAtom a2 = tb[i].getAtom2();
System.out.println( target.indexOf(a1) + " - " + target.indexOf(a2) );
}
}
|
Does this help?
Regards,
Miklos
User 031cf6afbd
04-03-2008 15:31:26
Hi Miklos ,
yeah your right , it was my fault ,everythings working fine now.
thanks again :-)
mohamed souiai
ChemAxon efa1591b5a
04-03-2008 15:49:58
I'm glad it works now.
Please come back to the forum if you have any further enquiry.
Miklos
User 031cf6afbd
10-03-2008 12:55:15
Hi Miklos;
i found something interessting the mcs.search () dont terminate at the following input attached.
regards
msouiai
ChemAxon efa1591b5a
13-03-2008 08:58:31
I will check this for you later today. However, the search options would be useful to know (e.g. atom and bond types were matched or ignored, exact, fast or turbo mode was applied etc.)
Thanks
Miklos
User 031cf6afbd
18-03-2008 20:51:54
Hi Miklos,
i haven't touched the options so everything should be in default mode.
regards
msouiai
ChemAxon efa1591b5a
19-03-2008 10:15:55
Hi,
huuuhh, these structures are monsters! :-)
No wonder it takes long to compute the MCS. Try the turbo mode by adding the
-m turbo option to the command line. It does find a large common core in one second, though there is no guarantee that it is the largest one. In case of your particular structures, though, I reckon (by 'eye inspection' only!) that it is the exact MCS.
Code: |
miklos-vargyas-computer:~/cvs/release/5.0/jchem mico$ time ./jchemsite/bin/mcs -q ~/work/test/data/mcs/referenceMolecule2.sdf -t ~/work/test/data/mcs/reconstructedMolecule2.sdf -m turbo
OCCOCCOCCOCC(COCCOCCOCCO)Oc1cc(cc(OC(COCCOCCOCCO)COCCOCCOCCO)c1OCCCOC(=O)CCC(C(O)=O)C(O)=O)C(=O)NCCCc1cc(CCCNC(=O)c2cc(OC(COCCO)COCCO)c(OCCCNS)c(OC(COCCO)COCCO)c2)cc(c1)C(O)=O
real 0m1.188s
user 0m0.988s
sys 0m0.101s
|
Does this help?
Regards,
Miklos
User 031cf6afbd
19-03-2008 12:00:07
Hi Miklos ,
yeah the turbo mode ist working finde with that example :-)
thanks
ChemAxon efa1591b5a
19-03-2008 13:01:10
I'm glad! ;-)
M