Hi,
in general we do not have much knowledge on PHP since we are working on Java and .Net environments. Besides i feel that it is a quite simple task to accomplish, without any knowledge about Java programming for a programmer.
And as I see we have included lots of links and by the way the web is full with example small Java programs, we have a documentation, and usage example for your program as a Java pseudocode, and as I have stated before, to call a java program from PHP can be done in one line with exec.
I felt that this is enough, but it seems it is not, I am not asking why, but I am a bit disapointed, because it is not even a semi pro but a newbie level issue.
Here you can find the main code in the Java class you need, package declaration is missing only (that is your task to find out if you need it, and even to find out if you want to place this class to a package):
import chemaxon.descriptors.DescriptorGenerator;
import chemaxon.descriptors.MDGeneratorException;
import chemaxon.formats.MolFormatException;
import chemaxon.formats.MolImporter;
import chemaxon.struc.Molecule;
public class ClassToCallFromPHP {
public static void main(String[] args) {
try {
DescriptorGenerator gen = new DescriptorGenerator("ECFP");
gen.setParameter("Length", "512");
Molecule mol = MolImporter.importMol("C1CCCCC1");
gen.generate(mol);
System.out.println(gen.getAsString());
} catch (Exception e) {
System.out.println("Error");
}
}
}
Here you can find the PHP code snippet to run this java code:
<?php
exec("java -cp \"path/to/jchem.jar\" path/to/ClassToCallFromPHP", $output, $retval);
if ($output[0]!="Error"){
// here comes the search code.
// the first and only element of the $output array contains the fingerprint
} else {
echo ("Oooops fingerprint generation failed.");
}
?>
Prerequisites to run the java code this way from PHP:
- Jchem jar available at the specified location for the running PHP script, JChem.jar is in its natural place where it was placed by installation.
- java is installed, and available for the PHP code in its Environments Path variable, otherwise full path is needed for the java executable. Of course PHP need the rigths to run it from the webserver
- you have a setup for the PHP module, that allows to use the exec method of PHP, usually in safe mode it is not working, and there are possibilities to make it unavailable thru configuration. You can find more information on this in the PHP documentation I have linked before, and you also can ask your ISP about the server settings when your program goes to a production environment from localhost.
I think this is the maximum that we can help on this question.
Regards,
Istvan