Search in sources :

Example 1 with IBitFingerprint

use of org.openscience.cdk.fingerprint.IBitFingerprint in project MetFragRelaunched by ipb-halle.

the class TanimotoSimilarityTest method toBitString.

private String toBitString(IBitFingerprint fp) {
    final StringBuilder bitStringBuilder = new StringBuilder();
    final BitSet bitSet = fp.asBitSet();
    for (int i = 0; i < bitSet.size(); i++) {
        boolean bit = bitSet.get(i);
        if (bit)
            bitStringBuilder.append("1");
        else
            bitStringBuilder.append("0");
    }
    return bitStringBuilder.toString();
}
Also used : BitSet(java.util.BitSet) IBitFingerprint(org.openscience.cdk.fingerprint.IBitFingerprint)

Example 2 with IBitFingerprint

use of org.openscience.cdk.fingerprint.IBitFingerprint in project MetFragRelaunched by ipb-halle.

the class TanimotoSimilarityTest method testFingerprint.

@Test
public void testFingerprint() throws Exception {
    // LKJPSUCKSLORMF-UHFFFAOYSA-N
    final String smiles = "CN(C(=O)NC1=CC=C(C=C1)Cl)OC";
    final IAtomContainer molecule = MoleculeFunctions.getAtomContainerFromSMILES(smiles);
    MoleculeFunctions.prepareAtomContainer(molecule, true);
    final IBitFingerprint fp = TanimotoSimilarity.calculateFingerPrint(molecule);
    final String bitStringOfFingerprint = this.toBitString(fp);
    assertThat(bitStringOfFingerprint, is(this.oldFingerprintString));
}
Also used : IBitFingerprint(org.openscience.cdk.fingerprint.IBitFingerprint) IAtomContainer(org.openscience.cdk.interfaces.IAtomContainer) Test(org.junit.Test)

Example 3 with IBitFingerprint

use of org.openscience.cdk.fingerprint.IBitFingerprint in project MetFragRelaunched by ipb-halle.

the class FingerPrintR method toBitString.

private static String toBitString(IBitFingerprint fp) {
    final StringBuilder bitStringBuilder = new StringBuilder();
    final BitSet bitSet = fp.asBitSet();
    for (int i = 0; i < bitSet.size(); i++) {
        boolean bit = bitSet.get(i);
        if (bit)
            bitStringBuilder.append("1");
        else
            bitStringBuilder.append("0");
    }
    return bitStringBuilder.toString();
}
Also used : BitSet(java.util.BitSet) IBitFingerprint(org.openscience.cdk.fingerprint.IBitFingerprint)

Example 4 with IBitFingerprint

use of org.openscience.cdk.fingerprint.IBitFingerprint in project MetFragRelaunched by ipb-halle.

the class FingerPrintR method calculateFingerprintFromSmiles.

public static String calculateFingerprintFromSmiles(String smiles) {
    final IAtomContainer con = getAtomContainerFromSmiles(smiles);
    MoleculeFunctions.prepareAtomContainer(con, true);
    final IBitFingerprint fingerprint = TanimotoSimilarity.calculateFingerPrint(con);
    return toBitString(fingerprint);
}
Also used : IBitFingerprint(org.openscience.cdk.fingerprint.IBitFingerprint) IAtomContainer(org.openscience.cdk.interfaces.IAtomContainer)

Example 5 with IBitFingerprint

use of org.openscience.cdk.fingerprint.IBitFingerprint in project MetFragRelaunched by ipb-halle.

the class MetFusionMoNASpectralSimilarityInitialiser method initScoreParameters.

@Override
public void initScoreParameters(Settings settings) throws Exception {
    /*
		 * 
		 */
    // initialise MoNA web service
    MoNARestWebService webService = new MoNARestWebService(settings);
    ((ProcessingStatus) settings.get(VariableNames.PROCESS_STATUS_OBJECT_NAME)).setProcessStatusString("Retrieving Results from MoNA");
    CandidateList candidatesFromMoNA = null;
    try {
        candidatesFromMoNA = webService.performSpectrumSimilaritySearch();
    } catch (Exception e) {
        settings.set(VariableNames.METFUSION_MONA_SPECTRAL_SIMILARITY_CANDIDATES_NAME, new CandidateList());
        e.printStackTrace();
        return;
    }
    for (int i = 0; i < candidatesFromMoNA.getNumberElements(); i++) {
        IBitFingerprint fingerprint = TanimotoSimilarity.calculateFingerPrint(candidatesFromMoNA.getElement(i).getAtomContainer());
        candidatesFromMoNA.getElement(i).setProperty("Fingerprint", fingerprint);
    }
    settings.set(VariableNames.METFUSION_MONA_SPECTRAL_SIMILARITY_CANDIDATES_NAME, candidatesFromMoNA);
}
Also used : IBitFingerprint(org.openscience.cdk.fingerprint.IBitFingerprint) MoNARestWebService(de.ipbhalle.metfraglib.functions.MoNARestWebService) CandidateList(de.ipbhalle.metfraglib.list.CandidateList) ProcessingStatus(de.ipbhalle.metfraglib.process.ProcessingStatus) IBitFingerprint(org.openscience.cdk.fingerprint.IBitFingerprint)

Aggregations

IBitFingerprint (org.openscience.cdk.fingerprint.IBitFingerprint)29 IAtomContainer (org.openscience.cdk.interfaces.IAtomContainer)10 BitSet (java.util.BitSet)7 Test (org.junit.Test)6 CDKException (org.openscience.cdk.exception.CDKException)6 IOException (java.io.IOException)4 ICountFingerprint (org.openscience.cdk.fingerprint.ICountFingerprint)4 AverageLinkageStrategy (com.apporiented.algorithm.clustering.AverageLinkageStrategy)3 ClusteringAlgorithm (com.apporiented.algorithm.clustering.ClusteringAlgorithm)3 PDistClusteringAlgorithm (com.apporiented.algorithm.clustering.PDistClusteringAlgorithm)3 BufferedReader (java.io.BufferedReader)3 CircularFingerprinter (org.openscience.cdk.fingerprint.CircularFingerprinter)3 SmilesParser (org.openscience.cdk.smiles.SmilesParser)3 CandidateList (de.ipbhalle.metfraglib.list.CandidateList)2 FileNotFoundException (java.io.FileNotFoundException)2 InputStream (java.io.InputStream)2 InputStreamReader (java.io.InputStreamReader)2 HashMap (java.util.HashMap)2 List (java.util.List)2 BitSetFingerprint (org.openscience.cdk.fingerprint.BitSetFingerprint)2