Git Product home page Git Product logo

morgancpp's Introduction

morgancpp: Efficient structure for storing and comparing Morgan fingerprints

Installation

The package can be installed directly from GitHub:

if( !require(devtools) ) install.packages("devtools")
devtools::install_github("ArtemSokolov/morgancpp")

Once installed, the package can be loaded through the standard library() interface:

library( morgancpp )

Example data

The package works with Morgan fingerprints specified as hexadecimal strings of length 512. An example set of 100,000 fingerprints is included with the package. It can be loaded as follows:

fn <- system.file( "examples/example1.txt.gz", package="morgancpp" )
fps <- scan( fn, what=character() )
# [1] "020000000000000000000100...
# [2] "020004000000000000808101...
# [3] "200000000000000000000000...

Computing similarity of fingerprints

The tanimoto similarity can be computed directly on hexadecimal strings:

tanimoto( fps[1], fps[1] )    # 1
tanimoto( fps[1], fps[2] )    # 0.1627907
tanimoto( fps[1], "FFF" )
# Error in tanimoto(fps[1], "FFF") : Input hex string must be of length 512

However, doing this for a large number of fingerprints will be slow. Instead, we can initialize the c++ data structure to store fingerprints in an effcient manner and query that structure for similarity:

m <- MorganFPS$new( fps )
# C++ object <0x559fa18f2c40> of class 'MorganFPS' <0x559fa484d570>

object.size(fps)
57467704 bytes

m$size()
[1] 25600000

Similarity between fingerprints in the structure can be computed by indexing:

m$tanimoto( 1, 1 )   # 1
m$tanimoto( 1, 2 )   # 0.1627907

The entire similarity profile against all other fingerprints in the collection can be obtained for compounds already in the collection (specified as index i) or new external compounds (specified as hexadecimal strings):

res1 <- m$tanimoto_all( 1 )       # Compound 1 against all 100,000 fingerprints
res2 <- m$tanimoto_ext( fps[1] )  # External compound against all 100,000 fingerprints

Additional documentation

Obtaining additional information about functionality of the package can be done through the standard R interface:

# All available functions
library( help = morgancpp )

# Help for individual functions / data structures
?morgancpp::tanimoto
?morgancpp::MorganFPS

# C++ docstrings providing full signatures of each method
morgancpp::MorganFPS

morgancpp's People

Contributors

artemsokolov avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.