Custom Metrics

User 71f9fd1282

09-09-2004 13:33:39

How can I define and use my own (custom) metric in the .jsp example?


I am using custom fingerprints implemented in classes FP*.java.





The similarity score between two fingerprints x and y should be computed according to xMy, where x is the first fingerprint, M a matrix and y the second fingerprint.


In more detail:


xMy is x*(M*y) that means, multiplication of Matrix M with "vector" y and afterwards multiplication of the resulting vector with "vector" x. The idea is that not only common bits in the two fingerprints should higher the score but also bits resembling "interchangeable substructures".








I modified the FP.java file the following way:





final static private String[] metrics = { "Tanimoto", "MyScore"}


final static private float[] defaultThresholds = { 0.3F, 0.3F }


...





Can the computation take place in the


public float getDissimilarity method?





there is a comment


// add new metrics here


and I inserted





case 1 :


int score=0; //"MyScore"


int DEFAULT_LENGTH=379; //length fingerprint


float[][] m = ...;








//read the single "Bits" of the two fingerprints....


for (i=0; i<DEFAULT_LENGTH;i++)


if (getKey(i)==1)


{


for (j=0;j<DEFAULT_LENGTH;j++)


{


if (((FP)other).getKey(j)==1)


{


score=score+m[j];


}


}


}





return score;








This does not work :(.


What else must I do (which files must I modify/create) to use my custom score in the .jsp-application?


Thanks for your help

ChemAxon efa1591b5a

13-09-2004 10:01:34

[Sorry for the delay...]





That is a bit tricky, I should say this is really an advanced topic.





From the API custom metrics can be used in a straightforward manner, but JSP needs an XML configuration that defines available metrics. Copy an existing XML configuration that belongs to a standard ChemAxon descriptor (you find some in the examples/config directory).


The important part is <ScreeningConfiguration>, this is where metrics are defined. You can easily modify it to your needs.


Depending on the current implementation of the ??Parameters.java class of your custom descriptor, you may need to add further methods that read the XML configuration file. This, however, is not too painfull if the only section in your config is <ScreeningConfiguration>.





Please feel free to send further requests in the forum if this brief response does not prove to be sufficient to support your work.





Regards


Miklos

User 71f9fd1282

14-09-2004 09:17:04

I modified the cfp.xml file and copied it in the jsp1_x folder (i am starting this later in the browser) as "screenconfig.xml". I modified it and now it looks like this ( I also want to use Tanimoto score):





<ScreeningConfiguration>


<ParametrizedMetrics>


<ParametrizedMetric Name="Tanimoto" ActiveFamily="Generic"


Metric="Tanimoto" Threshold="0.2"/>


</ParametrizedMetrics>





<otherMetrics>


<Metric Name="MyMetric" ActiveFamily="Generic"


Metric="MyMetric" Threshold="0.2" />


</otherMetrics>





</ScreeningConfiguration>





What else must I do now? How is the metric defined? Which modification in FPParameter.java are necessary?


Thanks until now.


Florian Pitschi

ChemAxon efa1591b5a

14-09-2004 09:36:22

The new metric should also be a ParameterizedMetric:





Code:



<ParametrizedMetrics>


    <ParametrizedMetric Name="Tanimoto" ActiveFamily="Generic" Metric="Tanimoto" Threshold="0.2"/>


    <ParametrizedMetric Name="MyMetric" ActiveFamily="Generic"


Metric="MyMetric" Threshold="0.2" />


</ParametrizedMetrics>








The file has to be stored in the database which you access from JSP. The easiest is to specify this file after the
Code:
-c
flag of
Code:
generatemd
when fingerprints are created and stored in the db.


However, such screening configuration can be added any time later by calling
Code:
generatemd
with the
Code:
a
command, see http://www.jchem.com/doc/user/GenerateMD.html#examples for usage example.





Regarding FPParameters.java: if your class is derived from CDParameters.java, then probably nothing more has to be done. We can work on this later. First check, if you find your metric listed in the metrics combo box in the jsp example after you loaded it into the db with
Code:
generatemd a
.





Regards


Miklos

User 71f9fd1282

14-09-2004 10:42:11

If I click on "query", the error message





Index: 0, Size: 0





is displayed. Must the .xml config file be placed in a specific folder or can I place it where I want (after I call generatemd a <structable> <FPname>)?

ChemAxon efa1591b5a

14-09-2004 10:46:35

The xml config file is not needed after it is added to the database. The example written in JSP takes the screening configuration from the database.


The error message refers to some other problem. Did your fingerprint work with the default metric (Tanimoto) in JSP? You get this error message since you added the nem metric but everything worked all right beforehands?





I suggest to continue the discussion in e-mail.


Regards


Miklos

ChemAxon 587f88acea

10-03-2005 13:47:22

Hi





Can I generate chemical fingerprints for a structure represented in smile format whose structure search can be either of the following





1. exact


2. similarity


3. substructure





If yes, what should be the configuration file settings I need? I have tested with the default configuration file provided by JChem (cfp.xml) in config folder. but i think i am wrong in some parameter settings.





Is this procedure right?





Please help me in this regard.





Thanks





Srinivas

ChemAxon efa1591b5a

10-03-2005 14:42:40

Hi,





I am not sure I fully understand your goals, please tell us more about the particular problem you try to solve.





In general: cfp.xml is used by the Screen tool for similarity calculations. Its default parameters (1024, 7, 3) are derived from a large number of virtual screening experiments and in most cases these values provide good results.





For substructure searching you do not need to generate the fingerprints, the search system does it in the background in a fully transparent manner when you import structures into your database.





Regards,


Miklos