com.actelion.research.calc.BinarySOM Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of openchemlib Show documentation
Show all versions of openchemlib Show documentation
Open Source Chemistry Library
/*
* Copyright 2017 Idorsia Pharmaceuticals Ltd., Hegenheimermattweg 91, CH-4123 Allschwil, Switzerland
*
* This file is part of DataWarrior.
*
* DataWarrior is free software: you can redistribute it and/or modify it under the terms of the
* GNU General Public License as published by the Free Software Foundation, either version 3 of
* the License, or (at your option) any later version.
*
* DataWarrior is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU General Public License for more details.
* You should have received a copy of the GNU General Public License along with DataWarrior.
* If not, see http://www.gnu.org/licenses/.
*
* @author Thomas Sander
*/
package com.actelion.research.calc;
import com.actelion.research.chem.SSSearcherWithIndex;
import java.awt.*;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Random;
public class BinarySOM extends SelfOrganizedMap {
private static final int KEY_COUNT = SSSearcherWithIndex.getNoOfKeys();
private static final int MASK_COUNT = (SSSearcherWithIndex.getNoOfKeys()+31)/32;
private double[] mKeyFrequency;
private int mMaxKeyCount;
private int[] mMask;
private int[][] mKeyMaskMap;
private ArrayList mRandomizedKeyIndexList;
private byte[] mBitCount;
private Random mRandom;
public BinarySOM() {
// constructor to be used if SOM interna are read from a SOM file with read()
init();
}
public BinarySOM(int nx, int ny, int mode) {
super(nx, ny, mode);
init();
}
private void init() {
mRandom = new Random();
mMask = new int[32];
mMask[0] = 0x80000000;
for (int i=0; i<31; i++)
mMask[i+1] = mMask[i] >>> 1;
mRandomizedKeyIndexList = new ArrayList();
for (int i=0; i");
writer.newLine();
}
public void read(BufferedReader reader) throws Exception {
super.read(reader);
String theLine = reader.readLine();
boolean error = !theLine.startsWith(">> 16];
allKeys += mBitCount[0xFFFF & ak] + mBitCount[ak >>> 16];
}
return 1.0 - (double)sharedKeys/(double)allKeys;
// return 1.0 - SSSearcherWithIndex.getSimilarityTanimoto((int[])vector1, (int[])vector2);
}
protected void updateReference(Object inputVector, Object referenceVector, double influence) {
int[] mask = mKeyMaskMap[(int)influence];
int[] inputKeyList = (int[])inputVector;
int[] referenceKeyList = (int[])referenceVector;
for (int i=0; i> 5] |= mMask[keyIndex & 0x1F];
if (mKeyMaskMap[keyCount] != null)
for (int i=0; i
© 2015 - 2025 Weber Informatics LLC | Privacy Policy