Giter Site home page Giter Site logo

kylelutz / chemkit Goto Github PK

View Code? Open in Web Editor NEW
53.0 53.0 26.0 8.58 MB

A C++ library for molecular modelling, cheminformatics and molecular visualization.

Home Page: http://www.chemkit.org

License: BSD 3-Clause "New" or "Revised" License

Python 5.19% C++ 91.23% Shell 0.49% C 0.50% CMake 2.30% Inno Setup 0.04% GLSL 0.25%

chemkit's People

Contributors

bradking avatar cryos avatar dlrdave avatar ktns avatar kylelutz avatar quizzmaster avatar soplwang avatar tufangorel avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

chemkit's Issues

Rewrite mdl file formats using STL iostreams

The mdl family of file formats (mdl, mol, sd, sdf) should be rewritten using std::istream and std::ostream instead of QIODevice.

The read() method in the MdlFileFormat class in the mdl plugin should be changed from:

bool read(QIODevice *iodev, chemkit::MoleculeFile *file)

to:

bool read(std::istream &input, chemkit::MoleculeFile *file)

And the write() method should be changed from:

bool write(const chemkit::MoleculeFile *file, QIODevice *iodev)

to:

bool write(const chemkit::MoleculeFile *file, std::ostream &output)

Rewrite mopin file format using STL iostreams

The mopin file format should be rewritten using std::istream instead of QIODevice.

The read() method in the MopinFileFormat class in the mopac plugin should be changed from:

bool read(QIODevice *iodev, chemkit::MoleculeFile *file)

to:

bool read(std::istream &input, chemkit::MoleculeFile *file)

Rewrite fhz file format using STL iostreams

The fhz file format should be rewritten using std::istream instead of QIODevice.

The read() method in the FhzFileFormat class in the fhz plugin should be changed from:

bool read(QIODevice *iodev, chemkit::MoleculeFile *file)

to:

bool read(std::istream &input, chemkit::MoleculeFile *file)

Error in weightedCenter function

There is an error in the function CartesianCoordinates::weightedCenter().

After summing the coordinates with their respective weights, the results gets divided by
the total mass times the number of particles. This is not correct. It should only be divided by
the total mass.

Segmentation fault in the delaunay triangulation

Hi.

I'm trying to debianize this package, and have encountered a segmentatoin fault.
When I build and test on an amd64 system, everything goes well.
However, when it comes on an i386 system (both on debian jessie and sid),
MolecularSurfaceTest::buckminsterfullerene() receives a segmentation fault.
I've managed to figure out that this segmentation fault is caused by -2 in the Tetrahedron::neighbors,
which seems to mean that DelaunayTriangulation::insertPoint cannot find a neighboring tetrahedron for a new tetrahedron.
Strangely enough, it does not receive a segfalt when it run under valgrind, yet valgrind reports no errors.

I'm not sure why and under what condition it happens, but I'm afraid that chemkit::geometry::planeOrientation goes unstable when it handles near-coplanar points in some environment.

What do you think?

Rewrite cube file format using STL iostreams

The cube file format should be rewritten using std::istream instead of QIODevice.

The read() method in the CubeFileFormat class in the cube plugin should be changed from:

bool read(QIODevice *iodev, chemkit::MoleculeFile *file)

to:

bool read(std::istream &input, chemkit::MoleculeFile *file)

Plugins directory.

The plugins directory should be set by hand after make install.
export CHEMKIT_PLUGIN_PATH=path_for_plugins_directory.

Rewrite mopcrt file format using STL iostreams

The mopcrt file format should be rewritten using std::istream instead of QIODevice.

The read() method in the MopcrtFileFormat class in the mopac plugin should be changed from:

bool read(QIODevice *iodev, chemkit::MoleculeFile *file)

to:

bool read(std::istream &input, chemkit::MoleculeFile *file)

Rewrite txyz file format using STL iostreams

The txyz file format should be rewritten using std::istream instead of QIODevice.

The read() method in the TxyzFileFormat class in the txyz plugin should be changed from:

bool read(QIODevice *iodev, chemkit::MoleculeFile *file)

to:

bool read(std::istream &input, chemkit::MoleculeFile *file)

And the write() method should be changed from:

bool write(const chemkit::MoleculeFile *file, QIODevice *iodev)

to:

bool write(const chemkit::MoleculeFile *file, std::ostream &output)

CMAKE on Windows Linker Errors

I had a linker error with nmake and it took hours to figure out how to fix this.

It tried to build dynamic libraries by linking against static boost libs.
Please have a look at these two files:

chemkit/CMakelists.txt (line 13):

if(WIN32)
set(Boost_USE_STATIC_LIBS ON)
endif()

chemkit/src/CMakelists.txt (line 8):

add_library(${library_name} DYNAMIC ${ARGN})

When i switch this from SHARED to STATIC, building with static boost libs works
properly for the core library, but not for the plugins.

The only way to compile the library is to manualy change the boost librarys per file
by removing the "lib" from "libboost..." filenames in the cmake-gui, but than the projects
depends on the boost-dll's.

Remove Qt dependency from libchemkit

Remove libchemkit's dependence on the Qt library. This will increase portability and improve performance for the core chemkit library. Qt's containers and algorithms should be replaced with their equivalents from STL and Boost.

Fix invalid memory read in ring perception

Problem: Valgrind reports an "Invalid read of size 4" in the SSSR implementation in the libchemkit library.

How to reproduce: Run valgrind on the benzimidazole method of the ring-perception auto test. The output is as follows:

$ valgrind ./ringperceptiontest benzimidazole
==25592== Memcheck, a memory error detector
==25592== Copyright (C) 2002-2010, and GNU GPL'd, by Julian Seward et al.
==25592== Using Valgrind-3.6.0.SVN-Debian and LibVEX; rerun with -h for copyright info
==25592== Command: ./ringperceptiontest benzimidazole
==25592== 
********* Start testing of RingPerceptionTest *********
Config: Using QTest library 4.7.0, Qt 4.7.0
PASS   : RingPerceptionTest::initTestCase()
==25592== Invalid read of size 4
==25592==    at 0x4E865D2: chemkit::(anonymous namespace)::Sssr::isUnique(std::vector > const&) const (in /home/kyle/dev/chemkit/build/src/chemkit/libchemkit.so)
==25592==    by 0x4E883D6: chemkit::MolecularGraph::sssr_rpPath(chemkit::MolecularGraph const*) (in /home/kyle/dev/chemkit/build/src/chemkit/libchemkit.so)
==25592==    by 0x4E826F6: chemkit::MolecularGraph::sssr(chemkit::Fragment const*) (in /home/kyle/dev/chemkit/build/src/chemkit/libchemkit.so)
==25592==    by 0x4E827EA: chemkit::MolecularGraph::sssr(chemkit::Molecule const*) (in /home/kyle/dev/chemkit/build/src/chemkit/libchemkit.so)
==25592==    by 0x4E91894: chemkit::Molecule::rings() const (in /home/kyle/dev/chemkit/build/src/chemkit/libchemkit.so)
==25592==    by 0x4E919A8: chemkit::Molecule::ringCount() const (in /home/kyle/dev/chemkit/build/src/chemkit/libchemkit.so)
==25592==    by 0x40FD06: RingPerceptionTest::benzimidazole() (in /home/kyle/dev/chemkit/build/tests/auto/chemkit/ring-perception/ringperceptiontest)
==25592==    by 0x42E987: RingPerceptionTest::qt_metacall(QMetaObject::Call, int, void**) (in /home/kyle/dev/chemkit/build/tests/auto/chemkit/ring-perception/ringperceptiontest)
==25592==    by 0x545CBF8: QMetaMethod::invoke(QObject*, Qt::ConnectionType, QGenericReturnArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument) const (in /usr/lib/libQtCore.so.4.7.0)
==25592==    by 0x545E305: QMetaObject::invokeMethod(QObject*, char const*, Qt::ConnectionType, QGenericReturnArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument) (in /usr/lib/libQtCore.so.4.7.0)
==25592==    by 0x50D1385: ??? (in /usr/lib/libQtTest.so.4.7.0)
==25592==    by 0x50D2321: QTest::qExec(QObject*, int, char**) (in /usr/lib/libQtTest.so.4.7.0)
==25592==  Address 0x8953ee4 is 0 bytes after a block of size 20 alloc'd
==25592==    at 0x4C28973: operator new(unsigned long) (vg_replace_malloc.c:261)
==25592==    by 0x4E6F229: std::vector >::vector(std::vector > const&) (in /home/kyle/dev/chemkit/build/src/chemkit/libchemkit.so)
==25592==    by 0x4E6FA0C: std::vector >, std::allocator > > >::_M_insert_aux(__gnu_cxx::__normal_iterator >*, std::vector >, std::allocator > > > >, std::vector > const&) (in /home/kyle/dev/chemkit/build/src/chemkit/libchemkit.so)
==25592==    by 0x4E88D1A: chemkit::MolecularGraph::sssr_rpPath(chemkit::MolecularGraph const*) (in /home/kyle/dev/chemkit/build/src/chemkit/libchemkit.so)
==25592==    by 0x4E826F6: chemkit::MolecularGraph::sssr(chemkit::Fragment const*) (in /home/kyle/dev/chemkit/build/src/chemkit/libchemkit.so)
==25592==    by 0x4E827EA: chemkit::MolecularGraph::sssr(chemkit::Molecule const*) (in /home/kyle/dev/chemkit/build/src/chemkit/libchemkit.so)
==25592==    by 0x4E91894: chemkit::Molecule::rings() const (in /home/kyle/dev/chemkit/build/src/chemkit/libchemkit.so)
==25592==    by 0x4E919A8: chemkit::Molecule::ringCount() const (in /home/kyle/dev/chemkit/build/src/chemkit/libchemkit.so)
==25592==    by 0x40FD06: RingPerceptionTest::benzimidazole() (in /home/kyle/dev/chemkit/build/tests/auto/chemkit/ring-perception/ringperceptiontest)
==25592==    by 0x42E987: RingPerceptionTest::qt_metacall(QMetaObject::Call, int, void**) (in /home/kyle/dev/chemkit/build/tests/auto/chemkit/ring-perception/ringperceptiontest)
==25592==    by 0x545CBF8: QMetaMethod::invoke(QObject*, Qt::ConnectionType, QGenericReturnArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument) const (in /usr/lib/libQtCore.so.4.7.0)
==25592==    by 0x545E305: QMetaObject::invokeMethod(QObject*, char const*, Qt::ConnectionType, QGenericReturnArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument, QGenericArgument) (in /usr/lib/libQtCore.so.4.7.0)
==25592== 
PASS   : RingPerceptionTest::benzimidazole()
PASS   : RingPerceptionTest::cleanupTestCase()
Totals: 3 passed, 0 failed, 0 skipped
********* Finished testing of RingPerceptionTest *********
==25592== 
==25592== HEAP SUMMARY:
==25592==     in use at exit: 760 bytes in 7 blocks
==25592==   total heap usage: 1,774 allocs, 1,767 frees, 57,684 bytes allocated
==25592== 
==25592== LEAK SUMMARY:
==25592==    definitely lost: 0 bytes in 0 blocks
==25592==    indirectly lost: 0 bytes in 0 blocks
==25592==      possibly lost: 0 bytes in 0 blocks
==25592==    still reachable: 760 bytes in 7 blocks
==25592==         suppressed: 0 bytes in 0 blocks
==25592== Rerun with --leak-check=full to see details of leaked memory
==25592== 
==25592== For counts of detected and suppressed errors, rerun with: -v
==25592== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 4 from 4)

chemkit.MoleculeFile should accept Python file objects

Right now, chemkit.MoleculeFile takes a filename passed as string.

This keeps you from doing useful things like wrapping a string as a file object with io.BytesIO. When you have a database / web query that returns Molfile information as a string, it's a pain to have to write it to a temporary file before parsing it with chemkit.

A possible alternative to overhauling the .read() method might be to add another method to moleculefile.pxi that lets you pass a string and bypass the GenericFile object all together.

malformed SDF string causes segfault

import chemkit
st = """ 2 1 0 0 0 0 999 V2000
... -0.4125 0.0000 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
... 0.4125 0.0000 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0"""
f = chemkit.MoleculeFile()
f.setFormat("sdf")
True
f.readString(st)
Segmentation fault: 11

For your copying and pasting pleasure, the string above is:

' 2 1 0 0 0 0 999 V2000\n -0.4125 0.0000 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0\n 0.4125 0.0000 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0\n'

Compiling examples

Hello !

I've been trying to compile the protein surface example following your step by step instructions. To get rid of the first compilation errors I had to add some Boost related entries in the CMakeLists :
find_package(Boost COMPONENTS iostreams filesystem system REQUIRED)
target_link_libraries(protein-surface-area ${CHEMKIT_LIBRARIES} ${Boost_LIBRARIES})

Errors are still showing up at linking :

[100%] Building CXX object CMakeFiles/protein-surface-area.dir/protein-surface-area.cpp.o
Linking CXX executable protein-surface-area
CMakeFiles/protein-surface-area.dir/protein-surface-area.cpp.o: In function `main':
protein-surface-area.cpp:(.text+0x4e): undefined reference to `chemkit::PolymerFile::PolymerFile(std::string const&)'
protein-surface-area.cpp:(.text+0xe3): undefined reference to `chemkit::PolymerFile::polymer(unsigned long) const'
protein-surface-area.cpp:(.text+0x25c): undefined reference to `chemkit::PolymerFile::~PolymerFile()'
protein-surface-area.cpp:(.text+0x2cb): undefined reference to `chemkit::PolymerFile::~PolymerFile()'
CMakeFiles/protein-surface-area.dir/protein-surface-area.cpp.o: In function `chemkit::GenericFile::read(std::istream&)':
protein-surface-area.cpp:(.text._ZN7chemkit11GenericFileINS_11PolymerFileENS_17PolymerFileFormatEE4readERSi[_ZN7chemkit11GenericFileINS_11PolymerFileENS_17PolymerFileFormatEE4readERSi]+0x20a): undefined reference to `chemkit::PolymerFileFormat::errorString() const'
collect2: error: ld returned 1 exit status
make[2]: *** [protein-surface-area] Error 1
make[1]: *** [CMakeFiles/protein-surface-area.dir/all] Error 2
make: *** [all] Error 2

I've tried both the stable version and latest git codes but I can't get past this error ...

Any idea ?

Thanks

Rewrite mol2 file format using STL iostreams

The mol2 file format should be rewritten using std::istream instead of QIODevice.

The read() method in the Mol2FileFormat class in the sybyl plugin should be changed from:

bool read(QIODevice *iodev, chemkit::MoleculeFile *file)

to:

bool read(std::istream &input, chemkit::MoleculeFile *file)

And the write() method should be changed from:

bool write(const chemkit::MoleculeFile *file, QIODevice *iodev)

to:

bool write(const chemkit::MoleculeFile *file, std::ostream &output)

Combile Error, the file moleculefileformat.h in src/io/CMakeLists.txt is named error

Hi,
When I want to install chemkit into system, there is a error:
CMake Error at src/io/cmake_install.cmake:54 (FILE):
file INSTALL cannot find
"/home/klniu/abs/chemkit/src/src/io/moledulefileformat.h".

I found in src/io/CMakeLists.txt the moleculefileformat.h file was named as moledulefileformat.h. It's a small issuse.

Thank you for your code. It's very useful and helpful.

Recards
Hugh

possible code errors

Hi,

In file internalcoordinates.cpp, It seems that the 2nd function should be multiplied by DegreesToRadians rather than RadiansToDegress. Also, the bond length r should not be multiplied by RadiansToDegrees, the same is true for ::coordinatesRidians().

// --- Coordinates --------------------------------------------------------- //
/// Sets the distance, angle, and torsion at \p row to \p r,
/// \p theta and \p phi respectively. The angles are in degrees.
void InternalCoordinates::setCoordinates(size_t row, Real r, Real theta, Real phi)
{
assert(row < d->size);

 d->coordinates[row * 3 + 0] = r;
 d->coordinates[row * 3 + 1] = theta;
 d->coordinates[row * 3 + 2] = phi;

}

/// Sets the distance, angle, and torsion at \p row to \p r,
/// \p theta and \p phi respectively. The angles are in radians.
void InternalCoordinates::setCoordinatesRadians(size_t row, Real r, Real theta, Real phi)
{
assert(row < d->size);

 d->coordinates[row * 3 + 0] = r * chemkit::constants::RadiansToDegrees;
 d->coordinates[row * 3 + 1] = theta * chemkit::constants::RadiansToDegrees;
 d->coordinates[row * 3 + 2] = phi * chemkit::constants::RadiansToDegrees;

}

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.