JOELib Tutorial: A Java based cheminformatics/computational chemistry package | ||
---|---|---|
Prev | Chapter 9. JOELib examples and code snippets | Next |
Processes can be get by using an instance or by using the factory helper class. In general getting plain instances of these process classes would be more easier, because most of them have special initialization methods, which must be called after getting an instance of these classes.
Example 9-17. Get a molecule process by creating an instance
JOEProcess process=new DescVarianceNorm();
Example 9-18. Get a molecule process by using the process factory
JOEProcess process=null; try { process= ProcessFactory.instance().getProcess("VarianceNormalization"); } catch (JOEProcessException ex) { // TODO: handle exception, when process can not be found }
Example 9-19. Use initialization method for a process (depends on the process!)
try { ((DescVarianceNorm)process).init(inType,inputFile); } catch (Exception ex) { // TODO: handle exception }
For building more complex process pies with applying special filter functionalities there exists a simple process pipe. More extended things, like process trees or somethings else sj´hould not be too difficult to implement.
Example 9-20. Get a molecule process pipe with filter functionalities
//initialize filter DescriptorFilter descFilter = new DescriptorFilter(); // filter accepts only molecules where all descriptors given by the // file at the descNamesURL exists. Commented descriptors names will // be ignored descFilter.init(descNamesURL, false); // initialize process and pipe DescSelectionWriter dsw = null; ProcessPipe processPipe = null; dsw = new DescSelectionWriter(); processPipe = new ProcessPipe(); // initialize output options for the // descriptor selection writer try { dsw.init(outputFile, outType, desc2write, descOutType); dsw.setDelimiter(delimiter); } catch (Exception ex) { } // use descriptor selection filter only when // all descriptor names given by the file at the // descNamesURL are available. // For more complex filter mechanism there // exists still AND and OR combinations for filters processPipe.addProcess(dsw, descFilter);
When a molecule has been loaded it is really simple the process: