Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: joelib/process/types/DistanceCalculation.java


1   ///////////////////////////////////////////////////////////////////////////////
2   //  Filename: $RCSfile: DistanceCalculation.java,v $
3   //  Purpose:  Counts the number of descriptors and molecules in a molecule file.
4   //  Language: Java
5   //  Compiler: JDK 1.4
6   //  Authors:  Joerg K. Wegner
7   //  Version:  $Revision: 1.5 $
8   //            $Date: 2003/08/22 15:56:20 $
9   //            $Author: wegner $
10  //
11  //  Copyright (c) Dept. Computer Architecture, University of Tuebingen, Germany
12  //
13  //  This program is free software; you can redistribute it and/or modify
14  //  it under the terms of the GNU General Public License as published by
15  //  the Free Software Foundation version 2 of the License.
16  //
17  //  This program is distributed in the hope that it will be useful,
18  //  but WITHOUT ANY WARRANTY; without even the implied warranty of
19  //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20  //  GNU General Public License for more details.
21  ///////////////////////////////////////////////////////////////////////////////
22  package joelib.process.types;
23  
24  import joelib.io.IOType;
25  
26  import joelib.molecule.JOEMol;
27  
28  import joelib.process.JOEProcessException;
29  import joelib.process.SimpleProcess;
30  
31  import joelib.util.ComparisonHelper;
32  import joelib.util.JOEProperty;
33  
34  /*==========================================================================*
35   * IMPORTS
36   *==========================================================================    */
37  import java.util.Map;
38  import java.util.Vector;
39  
40  import org.apache.log4j.Category;
41  
42  
43  /*==========================================================================*
44   * CLASS DECLARATION
45   *==========================================================================    */
46  
47  /**
48   *  Calling processor classes if the filter rule fits.
49   *
50   * @author     wegnerj
51   * @license    GPL
52   * @cvsversion    $Revision: 1.5 $, $Date: 2003/08/22 15:56:20 $
53   */
54  public class DistanceCalculation extends SimpleProcess
55  {
56      //~ Static fields/initializers /////////////////////////////////////////////
57  
58      /*-------------------------------------------------------------------------*
59       *  public static member variables
60       *-------------------------------------------------------------------------    */
61  
62      /**
63       *  Obtain a suitable logger.
64       */
65      private static Category logger = Category.getInstance(
66              "joelib.process.types.DistanceCalculation");
67  
68      //~ Instance fields ////////////////////////////////////////////////////////
69  
70      //  private final static  JOEProperty[]  ACCEPTED_PROPERTIES    = new JOEProperty[]{
71      //      new JOEProperty("NUMBER_OF_BINS", "java.lang.Integer", "Number of bins to create.", true),
72      //      };
73      private ComparisonHelper comparison;
74      private double[] distanceValues;
75  
76      //~ Constructors ///////////////////////////////////////////////////////////
77  
78      /*-------------------------------------------------------------------------*
79       *  constructor
80       *-------------------------------------------------------------------------    */
81  
82      /**
83       *  Constructor for the DescSelectionWriter object
84       */
85      public DistanceCalculation()
86      {
87          clear();
88      }
89  
90      //~ Methods ////////////////////////////////////////////////////////////////
91  
92      public final Vector getTargetMols()
93      {
94          return comparison.getTargetMols();
95      }
96  
97      public double[] getDistanceValues()
98      {
99          return distanceValues;
100     }
101 
102     /**
103      *  Description of the Method
104      *
105      * @return   Description of the Return Value
106      */
107     public boolean clear()
108     {
109         return true;
110     }
111 
112     /*-------------------------------------------------------------------------*
113      * public  methods
114      *-------------------------------------------------------------------------    */
115 
116     /**
117      * Description of the Method
118      *
119      * @param _statistic  Description of the Parameter
120      */
121     public void init(ComparisonHelper _comparison)
122     {
123         comparison = _comparison;
124     }
125 
126     /**
127      *  Description of the Method
128      *
129      * @param inType         Description of the Parameter
130      * @param inStream       Description of the Parameter
131      * @param _numberOfBins  Description of the Parameter
132      * @exception Exception  Description of the Exception
133      */
134     public void init(IOType inType, String targetFile, String descriptor)
135         throws Exception
136     {
137         logger.info("Checking target file for comparison.");
138         comparison = new ComparisonHelper(inType, targetFile);
139         comparison.setComparisonDescriptor(descriptor);
140     }
141 
142     public void init(IOType inType, String targetFile, String[] descriptors)
143         throws Exception
144     {
145         logger.info("Checking target file for comparison.");
146         comparison = new ComparisonHelper(inType, targetFile);
147         comparison.setComparisonDescriptors(descriptors);
148     }
149 
150     public void init(JOEMol target, String descriptor)
151         throws Exception
152     {
153         logger.info("Checking target file for comparison.");
154         comparison = new ComparisonHelper(target);
155         comparison.setComparisonDescriptor(descriptor);
156     }
157 
158     public void init(JOEMol target, String[] descriptors)
159         throws Exception
160     {
161         logger.info("Checking target file for comparison.");
162         comparison = new ComparisonHelper(target);
163         comparison.setComparisonDescriptors(descriptors);
164     }
165 
166     /**
167      *  Description of the Method
168      *
169      * @return   Description of the Return Value
170      */
171     public JOEProperty[] neededProperties()
172     {
173         //    return ACCEPTED_PROPERTIES;
174         return null;
175     }
176 
177     /**
178      *  Description of the Method
179      *
180      * @param mol                      Description of the Parameter
181      * @param properties               Description of the Parameter
182      * @return                         Description of the Return Value
183      * @exception JOEProcessException  Description of the Exception
184      */
185     public boolean process(JOEMol mol, Map properties)
186         throws JOEProcessException
187     {
188         if (comparison == null)
189         {
190             return false;
191         }
192 
193         try
194         {
195             super.process(mol, properties);
196         }
197          catch (JOEProcessException e)
198         {
199             throw new JOEProcessException("Properties for " +
200                 this.getClass().getName() + " not correct.");
201         }
202 
203         distanceValues = comparison.compare(mol, null, distanceValues);
204 
205         return true;
206     }
207 
208     /*-------------------------------------------------------------------------*
209      * private  methods
210      *-------------------------------------------------------------------------    */
211 }
212 ///////////////////////////////////////////////////////////////////////////////
213 //  END OF FILE.
214 ///////////////////////////////////////////////////////////////////////////////