Adds FreeSASA adapter (#1565)

* Adds FreeSASA adapter

* Uses windows branch when necessary

* Oops inverted windows and unix builds

* Fixes windows source build

* Adds downloading message

* Updates FreeSASA to final API

* Adds python API

* Finished queryatom API

* Changes d_alg to algorithm (and d_classifier) exposes to python adds docs/tests

* Adds FATAL_ERROR to MSVC builds, removes from appveyor
This commit is contained in:
Brian Kelley
2017-09-25 02:57:14 -04:00
committed by Greg Landrum
parent de2e7c7a31
commit 210935a92c
12 changed files with 1661 additions and 1 deletions

View File

@@ -1,3 +1,4 @@
add_subdirectory(INCHI-API)
add_subdirectory(AvalonTools)
add_subdirectory(FreeSASA)

87
External/FreeSASA/CMakeLists.txt vendored Normal file
View File

@@ -0,0 +1,87 @@
if(RDK_BUILD_FREESASA_SUPPORT)
if(NOT DEFINED FREESASA_DIR)
set(FREESASA_DIR "${CMAKE_CURRENT_SOURCE_DIR}/freesasa")
set(needDownload "TRUE")
if(EXISTS "${FREESASA_DIR}/src/freesasa.h")
set(needDownload "FALSE")
endif()
endif()
if(needDownload)
# don't actually use the md5 here
if(MSVC)
message(FATAL_ERROR "FreeSASA currently not working on windows. Come back soon!")
message("Downloading WINDOWS FREESASA source")
downloadAndCheckMD5("https://github.com/mittinatten/freesasa/archive/windows.tar.gz"
"${CMAKE_CURRENT_SOURCE_DIR}/master.tar.gz"
"")
execute_process(COMMAND ${CMAKE_COMMAND} -E tar zxf
${CMAKE_CURRENT_SOURCE_DIR}/master.tar.gz
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
set(FREESASA_SRC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/freesasa-windows")
set(FREESASA_GETLINE "getline.c")
else()
downloadAndCheckMD5("https://github.com/mittinatten/freesasa/archive/master.tar.gz"
"${CMAKE_CURRENT_SOURCE_DIR}/master.tar.gz"
"")
execute_process(COMMAND ${CMAKE_COMMAND} -E tar zxf
${CMAKE_CURRENT_SOURCE_DIR}/master.tar.gz
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
set(FREESASA_SRC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/freesasa-master")
set(FREESASA_GETLINE "")
endif()
endif()
macro(use_c99)
if (CMAKE_VERSION VERSION_LESS "3.1")
if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
set (CMAKE_C_FLAGS "--std=gnu99 ${CMAKE_C_FLAGS}")
endif ()
else ()
set (CMAKE_C_STANDARD 99)
endif ()
endmacro(use_c99)
use_c99()
message("Copying freesasa2.c to ${FREESASA_SRC_DIR}/src/freesasa2.c")
file(COPY freesasa2.c DESTINATION ${FREESASA_SRC_DIR}/src/)
set (freesasa_clib_srcs
${FREESASA_SRC_DIR}/src/classifier.c
${FREESASA_SRC_DIR}/src/classifier_naccess.c
${FREESASA_SRC_DIR}/src/classifier_oons.c
${FREESASA_SRC_DIR}/src/classifier_protor.c
${FREESASA_SRC_DIR}/src/coord.c
${FREESASA_SRC_DIR}/src/freesasa2.c
${FREESASA_SRC_DIR}/src/lexer.c
${FREESASA_SRC_DIR}/src/log.c
${FREESASA_SRC_DIR}/src/nb.c
${FREESASA_SRC_DIR}/src/node.c
${FREESASA_SRC_DIR}/src/parser.c
${FREESASA_SRC_DIR}/src/pdb.c
${FREESASA_SRC_DIR}/src/rsa.c
${FREESASA_SRC_DIR}/src/sasa_lr.c
${FREESASA_SRC_DIR}/src/sasa_sr.c
${FREESASA_SRC_DIR}/src/selection.c
${FREESASA_SRC_DIR}/src/structure.c
${FREESASA_SRC_DIR}/src/util.c
${FREESASA_GETLINE}
)
add_definitions(-DUSE_THREADS=0)
add_definitions(-DUSE_JSON=0)
add_definitions(-DUSE_XML=0)
rdkit_library(freesasa_clib ${freesasa_clib_srcs})
include_directories("${FREESASA_SRC_DIR}/src")
rdkit_library(FreeSASALib RDFreeSASA.cpp SHARED LINK_LIBRARIES freesasa_clib GraphMol DataStructs RDGeometryLib RDGeneral )
rdkit_headers(RDFreeSASA.h DEST GraphMol)
rdkit_test(testFreeSASALib testFreeSASA.cpp
LINK_LIBRARIES FreeSASALib freesasa_clib FileParsers SmilesParse
GraphMol DataStructs RDGeometryLib RDGeneral)
add_subdirectory(Wrap)
endif(RDK_BUILD_FREESASA_SUPPORT)

201
External/FreeSASA/RDFreeSASA.cpp vendored Normal file
View File

@@ -0,0 +1,201 @@
// Copyright (c) 2016, Novartis Institutes for BioMedical Research Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following
// disclaimer in the documentation and/or other materials provided
// with the distribution.
// * Neither the name of Novartis Institutes for BioMedical Research Inc.
// nor the names of its contributors may be used to endorse or promote
// products derived from this software without specific prior written
// permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
#include <GraphMol/RDKitBase.h>
#include <GraphMol/QueryOps.h>
#include <GraphMol/RDKitQueries.h>
#include <GraphMol/MonomerInfo.h>
#include <RDGeneral/types.h>
#include "RDFreeSASA.h"
#include "boost/format.hpp"
extern "C" {
#include "freesasa.h"
}
namespace RDKit {
namespace common_properties {
namespace Atom {
const std::string SASA = "SASA";; // Solvent Accessible Surface Area for atom- double
const std::string SASAClass = "SASAClass"; // Class type, 0,1,2... etc
const std::string SASAClassName = "SASAClassName"; // Class name, Polar, APolar etc...
}
namespace Molecule {
const std::string SASA = "SASA"; // Total Solvent Accessible Surface area for molecule;
}
}
}
namespace FreeSASA {
using namespace RDKit;
bool classifyAtoms(ROMol &mol, std::vector<double> &radii,
const SASAOpts &opts) {
radii.clear();
const freesasa_classifier *classifier = 0;
switch (opts.classifier) {
case SASAOpts::Protor:
classifier = &freesasa_protor_classifier;
break;
case SASAOpts::NACCESS:
classifier = &freesasa_naccess_classifier;
break;
case SASAOpts::OONS:
classifier = &freesasa_oons_classifier;
break;
default:
throw ValueErrorException("unknown FreeSASA classifier specified");
return false;
}
bool success = true;
for (ROMol::AtomIterator at = mol.beginAtoms(); at != mol.endAtoms(); ++at) {
Atom *atom = *at;
freesasa_atom_class cls = FREESASA_ATOM_UNKNOWN;
std::string classification = "Unclassified";
double radius = 0.0;
const AtomMonomerInfo *info = atom->getMonomerInfo();
if (info) {
const char *atom_name = info->getName().c_str();
const char *res_name = 0;
if (info->getMonomerType() == AtomMonomerInfo::PDBRESIDUE) {
res_name = ((AtomPDBResidueInfo *)info)->getResidueName().c_str();
radius = freesasa_classifier_radius(classifier, res_name, atom_name);
if (radius == 0.0) {
BOOST_LOG(rdWarningLog) << "Atom " << atom->getIdx()
<< " has zero radius" << std::endl;
}
cls = freesasa_classifier_class(classifier, res_name, atom_name);
if (cls == FREESASA_ATOM_UNKNOWN) {
BOOST_LOG(rdWarningLog) << "Atom " << atom->getIdx()
<< " could not be classified" << std::endl;
success = false;
} else {
classification = freesasa_classifier_class2str(cls);
}
}
}
radii.push_back(radius);
atom->setProp<int>(common_properties::Atom::SASAClass, (int)cls);
atom->setProp(common_properties::Atom::SASAClassName, classification);
}
return success;
}
namespace {
double internalCalcSASA(const ROMol &mol,
const std::vector<double> &radii,
int confIdx,
const SASAOpts &opts) {
PRECONDITION(mol.getNumConformers(), "No conformers in molecule");
PRECONDITION(confIdx < rdcast<int>(mol.getNumConformers()),
"Conformer index out of range");
PRECONDITION(mol.getNumAtoms(), "Empty molecule");
freesasa_parameters params = freesasa_default_parameters;
params.n_threads = 1;
switch (opts.algorithm) {
case SASAOpts::LeeRichards:
params.alg = FREESASA_LEE_RICHARDS;
break;
case SASAOpts::ShrakeRupley:
params.alg = FREESASA_SHRAKE_RUPLEY;
break;
default:
throw ValueErrorException("Unknown freesasa algorithm");
}
// sneaky, but legal :)
std::vector<double> coords(mol.getNumAtoms() * 3);
const RDGeom::POINT3D_VECT &vec = mol.getConformer(confIdx).getPositions();
for (size_t i = 0; i < mol.getNumAtoms(); ++i) {
coords[i * 3] = vec[i].x;
coords[i * 3 + 1] = vec[i].y;
coords[i * 3 + 2] = vec[i].z;
}
freesasa_result *res =
freesasa_calc_coord(&coords[0], &radii[0], mol.getNumAtoms(), &params);
if (!res) return 0.0;
CHECK_INVARIANT(res->n_atoms == rdcast<int>(mol.getNumAtoms()),
"freesasa didn't return the correct number of atoms");
double sasa = res->total;
mol.setProp(common_properties::Molecule::SASA, sasa);
size_t i = 0;
for (ROMol::ConstAtomIterator at = mol.beginAtoms(); at != mol.endAtoms();
++at, ++i) {
(*at)->setProp(common_properties::Atom::SASA, res->sasa[i]);
}
freesasa_result_free(res);
return sasa;
}
}
double calcSASA(const RDKit::ROMol &mol,
const std::vector<double> &radii,
int confIdx,
const RDKit::QueryAtom *query,
const SASAOpts &opts){
double result = internalCalcSASA(mol, radii, confIdx, opts);
if(query) {
result = 0.0f;
for (ROMol::ConstQueryAtomIterator at = mol.beginQueryAtoms(query);
at != mol.endQueryAtoms(); ++at) {
const Atom *atom = *at;
result += atom->getProp<double>("SASA");
}
}
return result;
}
const RDKit::QueryAtom * makeFreeSasaAPolarAtomQuery() {
QueryAtom *qa = new QueryAtom;
qa->setQuery(makePropQuery<Atom, std::string>("SASAClassName", "Apolar"));
return qa;
}
const RDKit::QueryAtom * makeFreeSasaPolarAtomQuery() {
QueryAtom *qa = new QueryAtom;
qa->setQuery(makePropQuery<Atom, std::string>("SASAClassName", "Polar"));
return qa;
}
}

115
External/FreeSASA/RDFreeSASA.h vendored Normal file
View File

@@ -0,0 +1,115 @@
// Copyright (c) 2016, Novartis Institutes for BioMedical Research Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following
// disclaimer in the documentation and/or other materials provided
// with the distribution.
// * Neither the name of Novartis Institutes for BioMedical Research Inc.
// nor the names of its contributors may be used to endorse or promote
// products derived from this software without specific prior written
// permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
#ifndef RDKIT_FREESASA_H
#define RDKIT_FREESASA_H
#include <GraphMol/RDKitBase.h>
namespace RDKit {
namespace common_properties {
namespace Atom {
extern const std::string SASA; // Solvent Accessible Surface Area for atom- double
extern const std::string SASAClass; // Class type, 0,1,2... etc
extern const std::string SASAClassName; // Class name, Polar, APolar etc...
}
namespace Molecule {
extern const std::string SASA; // Total Solvent Accessible Surface area for molecule;
}
}
}
namespace FreeSASA {
struct SASAOpts {
enum Algorithm { LeeRichards = 0, ShrakeRupley = 1 };
enum Classifier { Protor = 0, NACCESS = 1, OONS = 2 };
enum Classes { Unclassified = 0, APolar = 1, Polar = 2 };
Algorithm algorithm;
Classifier classifier;
SASAOpts() : algorithm(LeeRichards), classifier(Protor) {}
SASAOpts(Algorithm alg, Classifier cls) : algorithm(alg), classifier(cls) {}
};
//! Classify atoms using standard freesaa classifiers
/*!
Note:
FreeSASA identified Classes end up in atom.getProp<int>(common_properties::Atom::SASAClassName)
FreeSASA Class names end up in atom.getProp<string>(common_properties::Atom::SASAClassName)
\param mol: Molecule to analyze
\param radii output vector of radii where radii[idx] is the radius for atom with index idx
\return false if no atoms could be classified
*/
bool classifyAtoms(RDKit::ROMol &mol, std::vector<double> &radii,
const FreeSASA::SASAOpts &opts = SASAOpts());
//! calculate the Solvent Accessible Surface Area using the FreeSASA library.
/*!
SASA atom contribution data is stored in atom.getProp(common_properites::Atom::SASA);
\param mol: Molecule to analyze
\param radii vector of radii where radii[idx] is the radius for atom with index idx
These can be passed in or calculated with classifyAtoms for some proteins.
\param confIdx specify the conformation [default -1]
\param query query atom to limit the number of atoms to the ones matching the query
precanned query atoms can be made with makeFreeSasaPolarAtomQuery and
makeFreeSasaAPolarAtomQuery for classified polar and apolar atoms respectively.
\param opts SASAOpts class specifying options.
\return the requested solvent accessible surface area
*/
double calcSASA(const RDKit::ROMol &mol, const std::vector<double> &radii,
int confIdx=-1,
const RDKit::QueryAtom *query=NULL,
const SASAOpts &opts = SASAOpts());
//! Make a query atom returning the FreeSASA supplied apolar atom classification
/*!
These are atoms that have the "SASAClassName" property set to "Apolar"
after calling classifyAtoms.
\return QueryAtom pointer
*/
const RDKit::QueryAtom * makeFreeSasaAPolarAtomQuery();
//! Make a query atom returning the FreeSASA supplied polar atom classification
/*!
These are atoms that have the "SASAClassName" property set to "Polar"
after calling classifyAtoms.
\return QueryAtom pointer
*/
const RDKit::QueryAtom * makeFreeSasaPolarAtomQuery();
}
#endif

8
External/FreeSASA/Wrap/CMakeLists.txt vendored Normal file
View File

@@ -0,0 +1,8 @@
include_directories( ${RDKit_ExternalDir}/FreeSASA )
rdkit_python_extension(rdFreeSASA
rdFreeSASA.cpp
DEST Chem
LINK_LIBRARIES
FreeSASALib freesasa_clib GraphMol DataStructs RDGeometryLib RDGeneral RDBoost)
add_pytest(pyFreeSASA
${CMAKE_CURRENT_SOURCE_DIR}/testFreeSASA.py)

175
External/FreeSASA/Wrap/rdFreeSASA.cpp vendored Normal file
View File

@@ -0,0 +1,175 @@
// Copyright (c) 2017, Novartis Institutes for BioMedical Research Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following
// disclaimer in the documentation and/or other materials provided
// with the distribution.
// * Neither the name of Novartis Institutes for BioMedical Research Inc.
// nor the names of its contributors may be used to endorse or promote
// products derived from this software without specific prior written
// permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
#define NO_IMPORT_ARRAY
#include <RDBoost/python.h>
#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION
#include <numpy/arrayobject.h>
#include <boost/python/list.hpp>
//#include <boost/python/suite/indexing/map_indexing_suite.hpp>
//#include <boost/python/suite/indexing/vector_indexing_suite.hpp>
//#include <string>
#include <math.h>
#include <RDGeneral/Exceptions.h>
#include <GraphMol/RDKitBase.h>
#include <GraphMol/QueryAtom.h>
#include <RDFreeSASA.h>
#include <RDBoost/Wrap.h>
namespace python = boost::python;
namespace RDKit {
namespace {
python::object classifyAtomsHelper(RDKit::ROMol &mol,
const FreeSASA::SASAOpts &opts) {
std::vector<double> radii;
python::list l;
if (FreeSASA::classifyAtoms(mol, radii, opts)) {
for(size_t i=0;i<radii.size();++i)
l.append(radii[i]);
return l;
}
return l;
}
double calcSASAHelper(const RDKit::ROMol &mol,
python::object radii,
int confIdx,
const RDKit::Atom *query,
const FreeSASA::SASAOpts &opts) {
const RDKit::QueryAtom* atom = NULL;
if (query) {
atom = dynamic_cast<const RDKit::QueryAtom*>(query);
if (!atom) {
throw ValueErrorException("Query is not a query atom!");
}
}
std::vector<double> vradii;
unsigned int sz = python::extract<unsigned int>(radii.attr("__len__")());
for (unsigned int i = 0; i < sz; ++i) {
vradii.push_back(python::extract<double>(radii[i])());
}
return FreeSASA::calcSASA(mol, vradii, confIdx, atom, opts);
}
}
struct freesasa_wrapper {
static void wrap() {
std::string docString = "";
python::enum_<FreeSASA::SASAOpts::Algorithm>("SASAAlgorithm")
.value("LeeRichards", FreeSASA::SASAOpts::LeeRichards)
.value("ShrakeRupley", FreeSASA::SASAOpts::ShrakeRupley)
.export_values();
python::enum_<FreeSASA::SASAOpts::Classifier>("SASAClassifier")
.value("Protor", FreeSASA::SASAOpts::Protor)
.value("NACCESS", FreeSASA::SASAOpts::NACCESS)
.value("OONS", FreeSASA::SASAOpts::OONS)
.export_values();
python::enum_<FreeSASA::SASAOpts::Classes>("SASAClass")
.value("Unclassified", FreeSASA::SASAOpts::Unclassified)
.value("APolar", FreeSASA::SASAOpts::APolar)
.value("Polar", FreeSASA::SASAOpts::Polar)
.export_values();
python::class_<FreeSASA::SASAOpts>("SASAOpts", docString.c_str(),
python::init<>("Constructor takes no arguments"))
.def(python::init<FreeSASA::SASAOpts::Algorithm,
FreeSASA::SASAOpts::Classifier>())
.def_readwrite("algorithm", &FreeSASA::SASAOpts::algorithm)
.def_readwrite("classifier", &FreeSASA::SASAOpts::classifier)
;
docString = "Classify the atoms in the molecule returning their radii if possible.\n"
"ARGUMENTS:\n"
" - mol: molecule to classify\n"
" - options: FreeSASA options class specifying the classsification method.\n"
" Current classifiers are Protor, NACCESS and OONS\n"
" classification is stored as atom property 'SASAClass' for the integer value\n"
" and 'SASAClassName' for the string name of the class, Polar, APolar...\n"
"\n"
"RETURNS:\n"
" list of radii where radii[atom.GetIdx()] is the radii of the atom.\n"
" If classification fails, NONE is returned\n";
python::def("classifyAtoms", classifyAtomsHelper,
(python::arg("mol"),
python::arg("options") = FreeSASA::SASAOpts()),
docString.c_str());
docString = "Compute the Solvent Accessible Surface Area using the FreeSASA library\n"
"ARGUMENTS:\n"
" - mol: The molecule to compute.\n"
" - radii: A list of atom raddii where radii[atom.GetIdx()] is the radius of the atom\n"
" These can be passed in or calculated with classifyAtoms for some proteins\n"
" - confIdx: Specify the conformer to use for the 3D geometry [default -1]\n"
" - query: Pass along a query atom to compute the SASA for a subset of atoms.\n"
" precanned query atoms can be made with MakeFreeSasaPolarAtomQuery and\n"
" MakeFreeSasaAPolarAtomQuery for classified polar and apolar atoms respectively.\n"
" - opts: a SASAOpts class specifying the algorithm to use\n"
"\n"
"RETURNS:\n"
"The computed solvent accessible surface area.\n";
python::def("CalcSASA", calcSASAHelper,
(python::arg("mol"),
python::arg("radii"),
python::arg("confIdx")=-1,
python::arg("query")=python::object(),
python::arg("opts")=FreeSASA::SASAOpts()),
docString.c_str());
python::def("MakeFreeSasaAPolarAtomQuery", FreeSASA::makeFreeSasaAPolarAtomQuery,
python::return_value_policy<python::manage_new_object>(),
"Returns an APolar atom query for use with CalcSASA. An apolar atom has the SASAClass\n"
"and SASAClassName set to the APOLAR class. (see classifyAtoms)");
python::def("MakeFreeSasaPolarAtomQuery", FreeSASA::makeFreeSasaPolarAtomQuery,
python::return_value_policy<python::manage_new_object>(),
"Returns a polar atom query for use with CalcSASA. An polar atom has the SASAClass\n"
"and SASAClassName set to the POLAR class. (see classifyAtoms)");
}
};
}
BOOST_PYTHON_MODULE(rdFreeSASA) {
python::scope().attr("__doc__") =
"Module containing rdFreeSASA classes and functions.";
RDKit::freesasa_wrapper::wrap();
}

384
External/FreeSASA/Wrap/testFreeSASA.py vendored Normal file
View File

@@ -0,0 +1,384 @@
# Copyright (c) 2017, Novartis Institutes for BioMedical Research Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following
# disclaimer in the documentation and/or other materials provided
# with the distribution.
# * Neither the name of Novartis Institutes for BioMedical Research Inc.
# nor the names of its contributors may be used to endorse or promote
# products derived from this software without specific prior written
# permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
from __future__ import print_function
import unittest
import os,sys, copy
from rdkit.Chem import rdFreeSASA
from rdkit import Chem
expected = [
[0, 1, "Polar", 1.64], [1, 0, "Apolar", 1.88],
[2, 0, "Apolar", 1.61], [3, 1, "Polar", 1.42],
[4, 0, "Apolar", 1.88], [5, 0, "Apolar", 1.88],
[6, 1, "Polar", 1.77], [7, 0, "Apolar", 1.88],
[8, 1, "Polar", 1.64], [9, 0, "Apolar", 1.88],
[10, 0, "Apolar", 1.61], [11, 1, "Polar", 1.42],
[12, 0, "Apolar", 1.88], [13, 0, "Apolar", 1.88],
[14, 0, "Apolar", 1.61], [15, 1, "Polar", 1.42],
[16, 1, "Polar", 1.64], [17, 1, "Polar", 1.64],
[18, 0, "Apolar", 1.88], [19, 0, "Apolar", 1.61],
[20, 1, "Polar", 1.42], [21, 0, "Apolar", 1.88],
[22, 0, "Apolar", 1.88], [23, 0, "Apolar", 1.88],
[24, 0, "Apolar", 1.88], [25, 1, "Polar", 1.64],
[26, 0, "Apolar", 1.88], [27, 0, "Apolar", 1.61],
[28, 1, "Polar", 1.42], [29, 0, "Apolar", 1.88],
[30, 0, "Apolar", 1.61], [31, 0, "Apolar", 1.76],
[32, 0, "Apolar", 1.76], [33, 0, "Apolar", 1.76],
[34, 0, "Apolar", 1.76], [35, 0, "Apolar", 1.76],
[36, 1, "Polar", 1.64], [37, 0, "Apolar", 1.88],
[38, 0, "Apolar", 1.61], [39, 1, "Polar", 1.42],
[40, 0, "Apolar", 1.88], [41, 0, "Apolar", 1.88],
[42, 0, "Apolar", 1.88], [43, 1, "Polar", 1.64],
[44, 0, "Apolar", 1.88], [45, 0, "Apolar", 1.61],
[46, 1, "Polar", 1.42], [47, 0, "Apolar", 1.88],
[48, 0, "Apolar", 1.88], [49, 0, "Apolar", 1.88],
[50, 0, "Apolar", 1.88], [51, 1, "Polar", 1.64],
[52, 1, "Polar", 1.64], [53, 0, "Apolar", 1.88],
[54, 0, "Apolar", 1.61], [55, 1, "Polar", 1.42],
[56, 0, "Apolar", 1.88], [57, 1, "Polar", 1.46],
[58, 0, "Apolar", 1.88], [59, 1, "Polar", 1.64],
[60, 0, "Apolar", 1.88], [61, 0, "Apolar", 1.61],
[62, 1, "Polar", 1.42], [63, 0, "Apolar", 1.88],
[64, 0, "Apolar", 1.88], [65, 0, "Apolar", 1.88],
[66, 0, "Apolar", 1.88], [67, 1, "Polar", 1.64],
[68, 0, "Apolar", 1.88], [69, 0, "Apolar", 1.61],
[70, 1, "Polar", 1.42], [71, 0, "Apolar", 1.88],
[72, 1, "Polar", 1.46], [73, 0, "Apolar", 1.88],
[74, 1, "Polar", 1.64], [75, 0, "Apolar", 1.88],
[76, 0, "Apolar", 1.61], [77, 1, "Polar", 1.42],
[78, 1, "Polar", 1.64], [79, 0, "Apolar", 1.88],
[80, 0, "Apolar", 1.61], [81, 1, "Polar", 1.42],
[82, 0, "Apolar", 1.88], [83, 0, "Apolar", 1.88],
[84, 0, "Apolar", 1.88], [85, 0, "Apolar", 1.88],
[86, 1, "Polar", 1.64], [87, 1, "Polar", 1.64],
[88, 0, "Apolar", 1.88], [89, 0, "Apolar", 1.61],
[90, 1, "Polar", 1.42], [91, 0, "Apolar", 1.88],
[92, 1, "Polar", 1.46], [93, 0, "Apolar", 1.88],
[94, 1, "Polar", 1.64], [95, 0, "Apolar", 1.88],
[96, 0, "Apolar", 1.61], [97, 1, "Polar", 1.42],
[98, 0, "Apolar", 1.88], [99, 0, "Apolar", 1.88],
[100, 0, "Apolar", 1.88], [101, 0, "Apolar", 1.88],
[102, 1, "Polar", 1.64], [103, 0, "Apolar", 1.88],
[104, 0, "Apolar", 1.61], [105, 1, "Polar", 1.42],
[106, 0, "Apolar", 1.88], [107, 1, "Polar", 1.46],
[108, 0, "Apolar", 1.88], [109, 1, "Polar", 1.64],
[110, 0, "Apolar", 1.88], [111, 0, "Apolar", 1.61],
[112, 1, "Polar", 1.42], [113, 0, "Apolar", 1.88],
[114, 0, "Apolar", 1.88], [115, 0, "Apolar", 1.88],
[116, 0, "Apolar", 1.88], [117, 1, "Polar", 1.64],
[118, 0, "Apolar", 1.88], [119, 0, "Apolar", 1.61],
[120, 1, "Polar", 1.42], [121, 0, "Apolar", 1.88],
[122, 0, "Apolar", 1.88], [123, 0, "Apolar", 1.61],
[124, 1, "Polar", 1.42], [125, 1, "Polar", 1.46],
[126, 1, "Polar", 1.64], [127, 0, "Apolar", 1.88],
[128, 0, "Apolar", 1.61], [129, 1, "Polar", 1.42],
[130, 0, "Apolar", 1.88], [131, 0, "Apolar", 1.88],
[132, 0, "Apolar", 1.88], [133, 1, "Polar", 1.64],
[134, 0, "Apolar", 1.88], [135, 0, "Apolar", 1.61],
[136, 1, "Polar", 1.42], [137, 0, "Apolar", 1.88],
[138, 0, "Apolar", 1.88], [139, 0, "Apolar", 1.61],
[140, 1, "Polar", 1.42], [141, 1, "Polar", 1.46],
[142, 1, "Polar", 1.64], [143, 0, "Apolar", 1.88],
[144, 0, "Apolar", 1.61], [145, 1, "Polar", 1.42],
[146, 0, "Apolar", 1.88], [147, 0, "Apolar", 1.88],
[148, 0, "Apolar", 1.88], [149, 1, "Polar", 1.64],
[150, 0, "Apolar", 1.88], [151, 0, "Apolar", 1.61],
[152, 1, "Polar", 1.42], [153, 0, "Apolar", 1.88],
[154, 1, "Polar", 1.46], [155, 1, "Polar", 1.64],
[156, 0, "Apolar", 1.88], [157, 0, "Apolar", 1.61],
[158, 1, "Polar", 1.42], [159, 0, "Apolar", 1.88],
[160, 0, "Apolar", 1.61], [161, 1, "Polar", 1.42],
[162, 1, "Polar", 1.46], [163, 1, "Polar", 1.64],
[164, 0, "Apolar", 1.88], [165, 0, "Apolar", 1.61],
[166, 1, "Polar", 1.42], [167, 0, "Apolar", 1.88],
[168, 1, "Polar", 1.46], [169, 0, "Apolar", 1.88],
[170, 1, "Polar", 1.64], [171, 0, "Apolar", 1.88],
[172, 0, "Apolar", 1.61], [173, 1, "Polar", 1.42],
[174, 0, "Apolar", 1.88], [175, 0, "Apolar", 1.88],
[176, 0, "Apolar", 1.88], [177, 0, "Apolar", 1.88],
[178, 1, "Polar", 1.64], [179, 0, "Apolar", 1.88],
[180, 0, "Apolar", 1.61], [181, 1, "Polar", 1.42],
[182, 0, "Apolar", 1.88], [183, 0, "Apolar", 1.88],
[184, 0, "Apolar", 1.61], [185, 1, "Polar", 1.42],
[186, 1, "Polar", 1.46], [187, 1, "Polar", 1.64],
[188, 0, "Apolar", 1.88], [189, 0, "Apolar", 1.61],
[190, 1, "Polar", 1.42], [191, 0, "Apolar", 1.88],
[192, 0, "Apolar", 1.61], [193, 1, "Polar", 1.42],
[194, 1, "Polar", 1.64], [195, 1, "Polar", 1.64],
[196, 0, "Apolar", 1.88], [197, 0, "Apolar", 1.61],
[198, 1, "Polar", 1.42], [199, 0, "Apolar", 1.88],
[200, 0, "Apolar", 1.88], [201, 0, "Apolar", 1.88],
[202, 1, "Polar", 1.64], [203, 0, "Apolar", 1.88],
[204, 0, "Apolar", 1.61], [205, 1, "Polar", 1.42],
[206, 0, "Apolar", 1.88], [207, 0, "Apolar", 1.88],
[208, 0, "Apolar", 1.88], [209, 0, "Apolar", 1.88],
[210, 1, "Polar", 1.64], [211, 1, "Polar", 1.64],
[212, 0, "Apolar", 1.88], [213, 0, "Apolar", 1.61],
[214, 1, "Polar", 1.42], [215, 0, "Apolar", 1.88],
[216, 1, "Polar", 1.64], [217, 0, "Apolar", 1.88],
[218, 0, "Apolar", 1.61], [219, 1, "Polar", 1.42],
[220, 0, "Apolar", 1.88], [221, 0, "Apolar", 1.88],
[222, 0, "Apolar", 1.88], [223, 0, "Apolar", 1.88],
[224, 1, "Polar", 1.64], [225, 1, "Polar", 1.64],
[226, 0, "Apolar", 1.88], [227, 0, "Apolar", 1.61],
[228, 1, "Polar", 1.42], [229, 0, "Apolar", 1.88],
[230, 0, "Apolar", 1.88], [231, 0, "Apolar", 1.88],
[232, 0, "Apolar", 1.88], [233, 1, "Polar", 1.64],
[234, 0, "Apolar", 1.88], [235, 0, "Apolar", 1.61],
[236, 1, "Polar", 1.42], [237, 0, "Apolar", 1.88],
[238, 0, "Apolar", 1.88], [239, 0, "Apolar", 1.61],
[240, 1, "Polar", 1.42], [241, 1, "Polar", 1.64],
[242, 1, "Polar", 1.64], [243, 0, "Apolar", 1.88],
[244, 0, "Apolar", 1.61], [245, 1, "Polar", 1.42],
[246, 0, "Apolar", 1.88], [247, 0, "Apolar", 1.61],
[248, 1, "Polar", 1.42], [249, 1, "Polar", 1.46],
[250, 1, "Polar", 1.64], [251, 0, "Apolar", 1.88],
[252, 0, "Apolar", 1.61], [253, 1, "Polar", 1.42],
[254, 0, "Apolar", 1.88], [255, 0, "Apolar", 1.88],
[256, 0, "Apolar", 1.88], [257, 0, "Apolar", 1.88],
[258, 1, "Polar", 1.64], [259, 1, "Polar", 1.64],
[260, 0, "Apolar", 1.88], [261, 0, "Apolar", 1.61],
[262, 1, "Polar", 1.42], [263, 0, "Apolar", 1.88],
[264, 0, "Apolar", 1.88], [265, 0, "Apolar", 1.61],
[266, 1, "Polar", 1.42], [267, 1, "Polar", 1.46],
[268, 1, "Polar", 1.64], [269, 0, "Apolar", 1.88],
[270, 0, "Apolar", 1.61], [271, 1, "Polar", 1.42],
[272, 1, "Polar", 1.64], [273, 0, "Apolar", 1.88],
[274, 0, "Apolar", 1.61], [275, 1, "Polar", 1.42],
[276, 0, "Apolar", 1.88], [277, 0, "Apolar", 1.88],
[278, 0, "Apolar", 1.88], [279, 0, "Apolar", 1.88],
[280, 1, "Polar", 1.64], [281, 0, "Apolar", 1.88],
[282, 0, "Apolar", 1.61], [283, 1, "Polar", 1.42],
[284, 0, "Apolar", 1.88], [285, 0, "Apolar", 1.88],
[286, 0, "Apolar", 1.88], [287, 1, "Polar", 1.64],
[288, 0, "Apolar", 1.88], [289, 0, "Apolar", 1.61],
[290, 1, "Polar", 1.42], [291, 0, "Apolar", 1.88],
[292, 0, "Apolar", 1.88], [293, 0, "Apolar", 1.88],
[294, 1, "Polar", 1.64], [295, 0, "Apolar", 1.88],
[296, 0, "Apolar", 1.61], [297, 1, "Polar", 1.42],
[298, 0, "Apolar", 1.88], [299, 0, "Apolar", 1.61],
[300, 1, "Polar", 1.42], [301, 1, "Polar", 1.46],
[302, 1, "Polar", 1.64], [303, 0, "Apolar", 1.88],
[304, 0, "Apolar", 1.61], [305, 1, "Polar", 1.42],
[306, 0, "Apolar", 1.88], [307, 0, "Apolar", 1.88],
[308, 0, "Apolar", 1.61], [309, 1, "Polar", 1.42],
[310, 1, "Polar", 1.64], [311, 1, "Polar", 1.64],
[312, 0, "Apolar", 1.88], [313, 0, "Apolar", 1.61],
[314, 1, "Polar", 1.42], [315, 0, "Apolar", 1.88],
[316, 0, "Apolar", 1.88], [317, 0, "Apolar", 1.61],
[318, 1, "Polar", 1.42], [319, 1, "Polar", 1.64],
[320, 1, "Polar", 1.64], [321, 0, "Apolar", 1.88],
[322, 0, "Apolar", 1.61], [323, 1, "Polar", 1.42],
[324, 0, "Apolar", 1.88], [325, 0, "Apolar", 1.88],
[326, 0, "Apolar", 1.88], [327, 1, "Polar", 1.64],
[328, 0, "Apolar", 1.61], [329, 1, "Polar", 1.64],
[330, 1, "Polar", 1.64], [331, 1, "Polar", 1.64],
[332, 0, "Apolar", 1.88], [333, 0, "Apolar", 1.61],
[334, 1, "Polar", 1.42], [335, 0, "Apolar", 1.88],
[336, 0, "Apolar", 1.88], [337, 0, "Apolar", 1.88],
[338, 0, "Apolar", 1.88], [339, 1, "Polar", 1.64],
[340, 0, "Apolar", 1.88], [341, 0, "Apolar", 1.61],
[342, 1, "Polar", 1.42], [343, 0, "Apolar", 1.88],
[344, 0, "Apolar", 1.88], [345, 0, "Apolar", 1.88],
[346, 0, "Apolar", 1.88], [347, 1, "Polar", 1.64],
[348, 0, "Apolar", 1.88], [349, 0, "Apolar", 1.61],
[350, 1, "Polar", 1.42], [351, 0, "Apolar", 1.88],
[352, 0, "Apolar", 1.61], [353, 0, "Apolar", 1.76],
[354, 0, "Apolar", 1.76], [355, 0, "Apolar", 1.76],
[356, 0, "Apolar", 1.76], [357, 0, "Apolar", 1.76],
[358, 1, "Polar", 1.64], [359, 0, "Apolar", 1.88],
[360, 0, "Apolar", 1.61], [361, 1, "Polar", 1.42],
[362, 0, "Apolar", 1.88], [363, 1, "Polar", 1.64],
[364, 0, "Apolar", 1.88], [365, 0, "Apolar", 1.61],
[366, 1, "Polar", 1.42], [367, 1, "Polar", 1.64],
[368, 0, "Apolar", 1.88], [369, 0, "Apolar", 1.61],
[370, 1, "Polar", 1.42], [371, 0, "Apolar", 1.88],
[372, 0, "Apolar", 1.88], [373, 0, "Apolar", 1.88],
[374, 0, "Apolar", 1.88], [375, 1, "Polar", 1.64],
[376, 1, "Polar", 1.64], [377, 0, "Apolar", 1.88],
[378, 0, "Apolar", 1.61], [379, 1, "Polar", 1.42],
[380, 0, "Apolar", 1.88], [381, 0, "Apolar", 1.88],
[382, 0, "Apolar", 1.61], [383, 1, "Polar", 1.42],
[384, 1, "Polar", 1.64], [385, 1, "Polar", 1.64],
[386, 0, "Apolar", 1.88], [387, 0, "Apolar", 1.61],
[388, 1, "Polar", 1.42], [389, 0, "Apolar", 1.88],
[390, 0, "Apolar", 1.88], [391, 0, "Apolar", 1.88],
[392, 0, "Apolar", 1.88], [393, 1, "Polar", 1.64],
[394, 0, "Apolar", 1.88], [395, 0, "Apolar", 1.61],
[396, 1, "Polar", 1.42], [397, 0, "Apolar", 1.88],
[398, 0, "Apolar", 1.88], [399, 0, "Apolar", 1.61],
[400, 1, "Polar", 1.42], [401, 1, "Polar", 1.46],
[402, 1, "Polar", 1.64], [403, 0, "Apolar", 1.88],
[404, 0, "Apolar", 1.61], [405, 1, "Polar", 1.42],
[406, 0, "Apolar", 1.88], [407, 0, "Apolar", 1.61],
[408, 1, "Polar", 1.42], [409, 1, "Polar", 1.46],
[410, 1, "Polar", 1.64], [411, 0, "Apolar", 1.88],
[412, 0, "Apolar", 1.61], [413, 1, "Polar", 1.42],
[414, 1, "Polar", 1.64], [415, 0, "Apolar", 1.88],
[416, 0, "Apolar", 1.61], [417, 1, "Polar", 1.42],
[418, 0, "Apolar", 1.88], [419, 0, "Apolar", 1.88],
[420, 0, "Apolar", 1.88], [421, 1, "Polar", 1.64],
[422, 0, "Apolar", 1.61], [423, 1, "Polar", 1.64],
[424, 1, "Polar", 1.64], [425, 1, "Polar", 1.64],
[426, 0, "Apolar", 1.88], [427, 0, "Apolar", 1.61],
[428, 1, "Polar", 1.42], [429, 0, "Apolar", 1.88],
[430, 1, "Polar", 1.46], [431, 0, "Apolar", 1.88],
[432, 1, "Polar", 1.64], [433, 0, "Apolar", 1.88],
[434, 0, "Apolar", 1.61], [435, 1, "Polar", 1.42],
[436, 0, "Apolar", 1.88], [437, 0, "Apolar", 1.88],
[438, 0, "Apolar", 1.88], [439, 0, "Apolar", 1.88],
[440, 1, "Polar", 1.64], [441, 0, "Apolar", 1.88],
[442, 0, "Apolar", 1.61], [443, 1, "Polar", 1.42],
[444, 0, "Apolar", 1.88], [445, 1, "Polar", 1.46],
[446, 1, "Polar", 1.64], [447, 0, "Apolar", 1.88],
[448, 0, "Apolar", 1.61], [449, 1, "Polar", 1.42],
[450, 0, "Apolar", 1.88], [451, 0, "Apolar", 1.61],
[452, 1, "Polar", 1.42], [453, 1, "Polar", 1.46],
[454, 1, "Polar", 1.64], [455, 0, "Apolar", 1.88],
[456, 0, "Apolar", 1.61], [457, 1, "Polar", 1.42],
[458, 0, "Apolar", 1.88], [459, 0, "Apolar", 1.61],
[460, 0, "Apolar", 1.76], [461, 0, "Apolar", 1.76],
[462, 0, "Apolar", 1.76], [463, 0, "Apolar", 1.76],
[464, 0, "Apolar", 1.61], [465, 1, "Polar", 1.46],
[466, 1, "Polar", 1.64], [467, 0, "Apolar", 1.88],
[468, 0, "Apolar", 1.61], [469, 1, "Polar", 1.42],
[470, 0, "Apolar", 1.88], [471, 0, "Apolar", 1.61],
[472, 1, "Polar", 1.42], [473, 1, "Polar", 1.64],
[474, 1, "Polar", 1.64], [475, 0, "Apolar", 1.88],
[476, 0, "Apolar", 1.61], [477, 1, "Polar", 1.42],
[478, 0, "Apolar", 1.88], [479, 0, "Apolar", 1.88],
[480, 0, "Apolar", 1.88], [481, 0, "Apolar", 1.88],
[482, 1, "Polar", 1.64], [483, 0, "Apolar", 1.88],
[484, 0, "Apolar", 1.61], [485, 1, "Polar", 1.42],
[486, 0, "Apolar", 1.88], [487, 0, "Apolar", 1.88],
[488, 0, "Apolar", 1.61], [489, 1, "Polar", 1.42],
[490, 1, "Polar", 1.64], [491, 1, "Polar", 1.64],
[492, 0, "Apolar", 1.88], [493, 0, "Apolar", 1.61],
[494, 1, "Polar", 1.42], [495, 0, "Apolar", 1.88],
[496, 0, "Apolar", 1.88], [497, 0, "Apolar", 1.88],
[498, 0, "Apolar", 1.88], [499, 1, "Polar", 1.64],
[500, 1, "Polar", 1.64], [501, 0, "Apolar", 1.88],
[502, 0, "Apolar", 1.61], [503, 1, "Polar", 1.42],
[504, 0, "Apolar", 1.88], [505, 0, "Apolar", 1.88],
[506, 0, "Apolar", 1.61], [507, 1, "Polar", 1.42],
[508, 1, "Polar", 1.46], [509, 1, "Polar", 1.64],
[510, 0, "Apolar", 1.88], [511, 0, "Apolar", 1.61],
[512, 1, "Polar", 1.42], [513, 0, "Apolar", 1.88],
[514, 1, "Polar", 1.46], [515, 1, "Polar", 1.64],
[516, 0, "Apolar", 1.88], [517, 0, "Apolar", 1.61],
[518, 1, "Polar", 1.42], [519, 0, "Apolar", 1.88],
[520, 1, "Polar", 1.46], [521, 0, "Apolar", 1.88],
[522, 1, "Polar", 1.64], [523, 0, "Apolar", 1.88],
[524, 0, "Apolar", 1.61], [525, 1, "Polar", 1.42],
[526, 0, "Apolar", 1.88], [527, 0, "Apolar", 1.88],
[528, 0, "Apolar", 1.88], [529, 0, "Apolar", 1.88],
[530, 1, "Polar", 1.64], [531, 0, "Apolar", 1.88],
[532, 0, "Apolar", 1.61], [533, 1, "Polar", 1.42],
[534, 0, "Apolar", 1.88], [535, 0, "Apolar", 1.61],
[536, 1, "Polar", 1.64], [537, 0, "Apolar", 1.76],
[538, 0, "Apolar", 1.76], [539, 1, "Polar", 1.64],
[540, 1, "Polar", 1.64], [541, 0, "Apolar", 1.88],
[542, 0, "Apolar", 1.61], [543, 1, "Polar", 1.42],
[544, 0, "Apolar", 1.88], [545, 0, "Apolar", 1.88],
[546, 0, "Apolar", 1.88], [547, 0, "Apolar", 1.88],
[548, 1, "Polar", 1.64], [549, 0, "Apolar", 1.88],
[550, 0, "Apolar", 1.61], [551, 1, "Polar", 1.42],
[552, 0, "Apolar", 1.88], [553, 0, "Apolar", 1.88],
[554, 0, "Apolar", 1.88], [555, 1, "Polar", 1.64],
[556, 0, "Apolar", 1.88], [557, 0, "Apolar", 1.61],
[558, 1, "Polar", 1.42], [559, 0, "Apolar", 1.88],
[560, 0, "Apolar", 1.88], [561, 0, "Apolar", 1.88],
[562, 0, "Apolar", 1.88], [563, 1, "Polar", 1.64],
[564, 0, "Apolar", 1.88], [565, 0, "Apolar", 1.61],
[566, 1, "Polar", 1.42], [567, 0, "Apolar", 1.88],
[568, 0, "Apolar", 1.88], [569, 0, "Apolar", 1.88],
[570, 1, "Polar", 1.64], [571, 0, "Apolar", 1.61],
[572, 1, "Polar", 1.64], [573, 1, "Polar", 1.64],
[574, 1, "Polar", 1.64], [575, 0, "Apolar", 1.88],
[576, 0, "Apolar", 1.61], [577, 1, "Polar", 1.42],
[578, 0, "Apolar", 1.88], [579, 0, "Apolar", 1.88],
[580, 0, "Apolar", 1.88], [581, 0, "Apolar", 1.88],
[582, 1, "Polar", 1.64], [583, 0, "Apolar", 1.88],
[584, 0, "Apolar", 1.61], [585, 1, "Polar", 1.42],
[586, 0, "Apolar", 1.88], [587, 0, "Apolar", 1.88],
[588, 0, "Apolar", 1.88], [589, 1, "Polar", 1.64],
[590, 0, "Apolar", 1.61], [591, 1, "Polar", 1.64],
[592, 1, "Polar", 1.64], [593, 1, "Polar", 1.64],
[594, 0, "Apolar", 1.88], [595, 0, "Apolar", 1.61],
[596, 1, "Polar", 1.42], [597, 1, "Polar", 1.64],
[598, 0, "Apolar", 1.88], [599, 0, "Apolar", 1.61],
[600, 1, "Polar", 1.42], [601, 1, "Polar", 1.46]
]
class TestCase(unittest.TestCase) :
def test_basics(self):
fname = os.path.join(os.environ["RDBASE"],
"External", "FreeSASA", "freesasa-master", "tests", "data", "1d3z.pdb")
mol = Chem.MolFromPDBFile(fname)
radii = rdFreeSASA.classifyAtoms(mol)
for atom in mol.GetAtoms():
self.assertEqual( expected[atom.GetIdx()][3], radii[atom.GetIdx()] )
leeRichards = 5004.79964427
shrakerupley = 5000.340175
sasa = rdFreeSASA.CalcSASA(mol, radii=radii)
self.assertTrue( (sasa-leeRichards) < 1e-5 )
opts = rdFreeSASA.SASAOpts(rdFreeSASA.ShrakeRupley, rdFreeSASA.Protor)
sasa = rdFreeSASA.CalcSASA(mol, radii=radii, opts=opts)
self.assertTrue( (sasa-shrakerupley) < 1e-5 )
apolar = rdFreeSASA.CalcSASA(mol, radii, query=rdFreeSASA.MakeFreeSasaAPolarAtomQuery(), opts=opts);
polar = rdFreeSASA.CalcSASA(mol, radii, query=rdFreeSASA.MakeFreeSasaPolarAtomQuery(), opts=opts);
self.assertTrue( (polar + apolar - 5000.340175) < 1e-5 )
def test_opts(self):
fname = os.path.join(os.environ["RDBASE"],
"External", "FreeSASA", "freesasa-master", "tests", "data", "1d3z.pdb")
mol = Chem.MolFromPDBFile(fname)
radii = rdFreeSASA.classifyAtoms(mol)
for atom in mol.GetAtoms():
self.assertEqual( expected[atom.GetIdx()][3], radii[atom.GetIdx()] )
leeRichards = 5004.79964427
shrakerupley = 5000.340175
opts = rdFreeSASA.SASAOpts()
for alg, res in ( (rdFreeSASA.ShrakeRupley, shrakerupley),
(rdFreeSASA.LeeRichards, leeRichards)):
opts.algorithm = alg
sasa = rdFreeSASA.CalcSASA(mol, radii=radii, opts=opts)
self.assertTrue( abs(sasa-res) < 1e-5 )
if __name__ == '__main__':
unittest.main()

259
External/FreeSASA/freesasa2.c vendored Normal file
View File

@@ -0,0 +1,259 @@
/**
This source file contains everything that is in freesasa.h
interface and does not have a natural home in any of the other
source files.
*/
#if HAVE_CONFIG_H
# include <config.h>
#endif
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include "freesasa_internal.h"
#ifdef PACKAGE_VERSION
const char *freesasa_version = PACKAGE_VERSION;
#else
const char *freesasa_version = "";
#endif
#ifdef PACKAGE_STRING
const char *freesasa_string = PACKAGE_STRING;
#else
const char *freesasa_string = "FreeSASA";
#endif
// Allows compilation with different defaults
// depending on USE_THREADS. but still exposing the value in a header
// that doesn't depend on USE_THREADS
#ifdef USE_THREADS
#define DEF_NUMBER_THREADS 2
#else
#define DEF_NUMBER_THREADS 1
#endif
const int FREESASA_DEF_NUMBER_THREADS = DEF_NUMBER_THREADS;
const freesasa_parameters freesasa_default_parameters = {
.alg = FREESASA_DEF_ALGORITHM,
.probe_radius = FREESASA_DEF_PROBE_RADIUS,
.shrake_rupley_n_points = FREESASA_DEF_SR_N,
.lee_richards_n_slices = FREESASA_DEF_LR_N,
.n_threads = DEF_NUMBER_THREADS,
};
static freesasa_result *
result_new(int n)
{
freesasa_result *result = malloc(sizeof(freesasa_result));
if (result == NULL) {
mem_fail();
return NULL;
}
result->sasa = malloc(sizeof(double) * n);
if (result->sasa == NULL) {
mem_fail();
freesasa_result_free(result);
return NULL;
}
result->n_atoms = n;
return result;
}
void
freesasa_result_free(freesasa_result *r)
{
if (r) {
free(r->sasa);
free(r);
}
}
freesasa_result*
freesasa_calc(const coord_t *c,
const double *radii,
const freesasa_parameters *parameters)
{
assert(c);
assert(radii);
freesasa_result *result = result_new(freesasa_coord_n(c));
int ret;
if (result == NULL) {
fail_msg("");
return NULL;
}
if (parameters == NULL) parameters = &freesasa_default_parameters;
switch(parameters->alg) {
case FREESASA_SHRAKE_RUPLEY:
ret = freesasa_shrake_rupley(result->sasa, c, radii, parameters);
break;
case FREESASA_LEE_RICHARDS:
ret = freesasa_lee_richards(result->sasa, c, radii, parameters);
break;
default:
assert(0); //should never get here
break;
}
if (ret == FREESASA_FAIL) {
freesasa_result_free(result);
return NULL;
}
result->total = 0;
for (int i = 0; i < freesasa_coord_n(c); ++i) {
result->total += result->sasa[i];
}
result->parameters = *parameters;
return result;
}
freesasa_result*
freesasa_calc_coord(const double *xyz,
const double *radii,
int n,
const freesasa_parameters *parameters)
{
assert(xyz);
assert(radii);
assert(n > 0);
coord_t *coord = NULL;
freesasa_result *result = NULL;
coord = freesasa_coord_new_linked(xyz,n);
if (coord != NULL) result = freesasa_calc(coord, radii, parameters);
if (result == NULL) fail_msg("");
freesasa_coord_free(coord);
return result;
}
freesasa_result*
freesasa_calc_structure(const freesasa_structure* structure,
const freesasa_parameters* parameters)
{
assert(structure);
return freesasa_calc(freesasa_structure_xyz(structure),
freesasa_structure_radius(structure),
parameters);
}
freesasa_node *
freesasa_calc_tree(const freesasa_structure *structure,
const freesasa_parameters *parameters,
const char *name)
{
assert(structure);
freesasa_node *tree = NULL;
freesasa_result *result = freesasa_calc(freesasa_structure_xyz(structure),
freesasa_structure_radius(structure),
parameters);
if (result != NULL) {
tree = freesasa_tree_init(result, structure, name);
} else {
fail_msg("");
}
if (tree == NULL) {
fail_msg("");
}
freesasa_result_free(result);
return tree;
}
static inline void
count_err(int return_value, int *n_err)
{
if (return_value == FREESASA_FAIL) {
(*n_err)++;
}
}
int
freesasa_tree_export(FILE *file,
freesasa_node *root,
int options)
{
assert(freesasa_node_type(root) == FREESASA_NODE_ROOT);
int n_err = 0;
if (options & FREESASA_LOG) {
count_err(freesasa_write_log(file, root), &n_err);
}
if (options & FREESASA_RES) {
count_err(freesasa_write_res(file, root), &n_err);
}
if (options & FREESASA_SEQ) {
count_err(freesasa_write_seq(file, root), &n_err);
}
if (options & FREESASA_PDB) {
count_err(freesasa_write_pdb(file, root), &n_err);
}
if (options & FREESASA_RSA) {
count_err(freesasa_write_rsa(file, root, options), &n_err);
}
if (options & FREESASA_JSON) {
#if USE_JSON
count_err(freesasa_write_json(file, root, options), &n_err);
#else
return fail_msg("library was built without support for JSON output");
#endif
}
if (options & FREESASA_XML) {
#if USE_XML
count_err(freesasa_write_xml(file, root, options), &n_err);
#else
return fail_msg("library was built without support for XML output");
#endif
}
if (n_err > 0) {
return fail_msg("there were errors when writing output");
}
return FREESASA_SUCCESS;
}
freesasa_result *
freesasa_result_clone(const freesasa_result *result)
{
freesasa_result *clone = result_new(result->n_atoms);
if (clone == NULL) {
fail_msg("");
return NULL;
}
clone->n_atoms = result->n_atoms;
clone->total = result->total;
clone->parameters = result->parameters;
memcpy(clone->sasa, result->sasa, sizeof(double) * clone->n_atoms);
return clone;
}
const char*
freesasa_alg_name(freesasa_algorithm alg)
{
switch(alg) {
case FREESASA_SHRAKE_RUPLEY:
return "Shrake & Rupley";
case FREESASA_LEE_RICHARDS:
return "Lee & Richards";
}
assert(0 && "Illegal algorithm");
}

15
External/FreeSASA/getline.c vendored Normal file
View File

@@ -0,0 +1,15 @@
#include <sys/types.h>
#include <stdio.h>
#include <assert.h>
#include <errno.h>
int
getline (lineptr, n, stream)
char **lineptr;
size_t *n;
FILE *stream;
{
// do nothing implementation
// we don't use these functionalities of freesasa
return 0;
}

414
External/FreeSASA/testFreeSASA.cpp vendored Normal file
View File

@@ -0,0 +1,414 @@
// Copyright (c) 2016, Novartis Institutes for BioMedical Research Inc.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following
// disclaimer in the documentation and/or other materials provided
// with the distribution.
// * Neither the name of Novartis Institutes for BioMedical Research Inc.
// nor the names of its contributors may be used to endorse or promote
// products derived from this software without specific prior written
// permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
#include "RDFreeSASA.h"
#include <GraphMol/RDKitBase.h>
#include <GraphMol/SmilesParse/SmilesParse.h>
#include <GraphMol/FileParsers/FileParsers.h>
using namespace RDKit;
struct ExpectedClasses {
unsigned int idx;
int cls;
const char *clsname;
double radius;
};
ExpectedClasses ExpectedProtor1d3z[] = {
{0, 1, "Polar", 1.64}, {1, 0, "Apolar", 1.88},
{2, 0, "Apolar", 1.61}, {3, 1, "Polar", 1.42},
{4, 0, "Apolar", 1.88}, {5, 0, "Apolar", 1.88},
{6, 1, "Polar", 1.77}, {7, 0, "Apolar", 1.88},
{8, 1, "Polar", 1.64}, {9, 0, "Apolar", 1.88},
{10, 0, "Apolar", 1.61}, {11, 1, "Polar", 1.42},
{12, 0, "Apolar", 1.88}, {13, 0, "Apolar", 1.88},
{14, 0, "Apolar", 1.61}, {15, 1, "Polar", 1.42},
{16, 1, "Polar", 1.64}, {17, 1, "Polar", 1.64},
{18, 0, "Apolar", 1.88}, {19, 0, "Apolar", 1.61},
{20, 1, "Polar", 1.42}, {21, 0, "Apolar", 1.88},
{22, 0, "Apolar", 1.88}, {23, 0, "Apolar", 1.88},
{24, 0, "Apolar", 1.88}, {25, 1, "Polar", 1.64},
{26, 0, "Apolar", 1.88}, {27, 0, "Apolar", 1.61},
{28, 1, "Polar", 1.42}, {29, 0, "Apolar", 1.88},
{30, 0, "Apolar", 1.61}, {31, 0, "Apolar", 1.76},
{32, 0, "Apolar", 1.76}, {33, 0, "Apolar", 1.76},
{34, 0, "Apolar", 1.76}, {35, 0, "Apolar", 1.76},
{36, 1, "Polar", 1.64}, {37, 0, "Apolar", 1.88},
{38, 0, "Apolar", 1.61}, {39, 1, "Polar", 1.42},
{40, 0, "Apolar", 1.88}, {41, 0, "Apolar", 1.88},
{42, 0, "Apolar", 1.88}, {43, 1, "Polar", 1.64},
{44, 0, "Apolar", 1.88}, {45, 0, "Apolar", 1.61},
{46, 1, "Polar", 1.42}, {47, 0, "Apolar", 1.88},
{48, 0, "Apolar", 1.88}, {49, 0, "Apolar", 1.88},
{50, 0, "Apolar", 1.88}, {51, 1, "Polar", 1.64},
{52, 1, "Polar", 1.64}, {53, 0, "Apolar", 1.88},
{54, 0, "Apolar", 1.61}, {55, 1, "Polar", 1.42},
{56, 0, "Apolar", 1.88}, {57, 1, "Polar", 1.46},
{58, 0, "Apolar", 1.88}, {59, 1, "Polar", 1.64},
{60, 0, "Apolar", 1.88}, {61, 0, "Apolar", 1.61},
{62, 1, "Polar", 1.42}, {63, 0, "Apolar", 1.88},
{64, 0, "Apolar", 1.88}, {65, 0, "Apolar", 1.88},
{66, 0, "Apolar", 1.88}, {67, 1, "Polar", 1.64},
{68, 0, "Apolar", 1.88}, {69, 0, "Apolar", 1.61},
{70, 1, "Polar", 1.42}, {71, 0, "Apolar", 1.88},
{72, 1, "Polar", 1.46}, {73, 0, "Apolar", 1.88},
{74, 1, "Polar", 1.64}, {75, 0, "Apolar", 1.88},
{76, 0, "Apolar", 1.61}, {77, 1, "Polar", 1.42},
{78, 1, "Polar", 1.64}, {79, 0, "Apolar", 1.88},
{80, 0, "Apolar", 1.61}, {81, 1, "Polar", 1.42},
{82, 0, "Apolar", 1.88}, {83, 0, "Apolar", 1.88},
{84, 0, "Apolar", 1.88}, {85, 0, "Apolar", 1.88},
{86, 1, "Polar", 1.64}, {87, 1, "Polar", 1.64},
{88, 0, "Apolar", 1.88}, {89, 0, "Apolar", 1.61},
{90, 1, "Polar", 1.42}, {91, 0, "Apolar", 1.88},
{92, 1, "Polar", 1.46}, {93, 0, "Apolar", 1.88},
{94, 1, "Polar", 1.64}, {95, 0, "Apolar", 1.88},
{96, 0, "Apolar", 1.61}, {97, 1, "Polar", 1.42},
{98, 0, "Apolar", 1.88}, {99, 0, "Apolar", 1.88},
{100, 0, "Apolar", 1.88}, {101, 0, "Apolar", 1.88},
{102, 1, "Polar", 1.64}, {103, 0, "Apolar", 1.88},
{104, 0, "Apolar", 1.61}, {105, 1, "Polar", 1.42},
{106, 0, "Apolar", 1.88}, {107, 1, "Polar", 1.46},
{108, 0, "Apolar", 1.88}, {109, 1, "Polar", 1.64},
{110, 0, "Apolar", 1.88}, {111, 0, "Apolar", 1.61},
{112, 1, "Polar", 1.42}, {113, 0, "Apolar", 1.88},
{114, 0, "Apolar", 1.88}, {115, 0, "Apolar", 1.88},
{116, 0, "Apolar", 1.88}, {117, 1, "Polar", 1.64},
{118, 0, "Apolar", 1.88}, {119, 0, "Apolar", 1.61},
{120, 1, "Polar", 1.42}, {121, 0, "Apolar", 1.88},
{122, 0, "Apolar", 1.88}, {123, 0, "Apolar", 1.61},
{124, 1, "Polar", 1.42}, {125, 1, "Polar", 1.46},
{126, 1, "Polar", 1.64}, {127, 0, "Apolar", 1.88},
{128, 0, "Apolar", 1.61}, {129, 1, "Polar", 1.42},
{130, 0, "Apolar", 1.88}, {131, 0, "Apolar", 1.88},
{132, 0, "Apolar", 1.88}, {133, 1, "Polar", 1.64},
{134, 0, "Apolar", 1.88}, {135, 0, "Apolar", 1.61},
{136, 1, "Polar", 1.42}, {137, 0, "Apolar", 1.88},
{138, 0, "Apolar", 1.88}, {139, 0, "Apolar", 1.61},
{140, 1, "Polar", 1.42}, {141, 1, "Polar", 1.46},
{142, 1, "Polar", 1.64}, {143, 0, "Apolar", 1.88},
{144, 0, "Apolar", 1.61}, {145, 1, "Polar", 1.42},
{146, 0, "Apolar", 1.88}, {147, 0, "Apolar", 1.88},
{148, 0, "Apolar", 1.88}, {149, 1, "Polar", 1.64},
{150, 0, "Apolar", 1.88}, {151, 0, "Apolar", 1.61},
{152, 1, "Polar", 1.42}, {153, 0, "Apolar", 1.88},
{154, 1, "Polar", 1.46}, {155, 1, "Polar", 1.64},
{156, 0, "Apolar", 1.88}, {157, 0, "Apolar", 1.61},
{158, 1, "Polar", 1.42}, {159, 0, "Apolar", 1.88},
{160, 0, "Apolar", 1.61}, {161, 1, "Polar", 1.42},
{162, 1, "Polar", 1.46}, {163, 1, "Polar", 1.64},
{164, 0, "Apolar", 1.88}, {165, 0, "Apolar", 1.61},
{166, 1, "Polar", 1.42}, {167, 0, "Apolar", 1.88},
{168, 1, "Polar", 1.46}, {169, 0, "Apolar", 1.88},
{170, 1, "Polar", 1.64}, {171, 0, "Apolar", 1.88},
{172, 0, "Apolar", 1.61}, {173, 1, "Polar", 1.42},
{174, 0, "Apolar", 1.88}, {175, 0, "Apolar", 1.88},
{176, 0, "Apolar", 1.88}, {177, 0, "Apolar", 1.88},
{178, 1, "Polar", 1.64}, {179, 0, "Apolar", 1.88},
{180, 0, "Apolar", 1.61}, {181, 1, "Polar", 1.42},
{182, 0, "Apolar", 1.88}, {183, 0, "Apolar", 1.88},
{184, 0, "Apolar", 1.61}, {185, 1, "Polar", 1.42},
{186, 1, "Polar", 1.46}, {187, 1, "Polar", 1.64},
{188, 0, "Apolar", 1.88}, {189, 0, "Apolar", 1.61},
{190, 1, "Polar", 1.42}, {191, 0, "Apolar", 1.88},
{192, 0, "Apolar", 1.61}, {193, 1, "Polar", 1.42},
{194, 1, "Polar", 1.64}, {195, 1, "Polar", 1.64},
{196, 0, "Apolar", 1.88}, {197, 0, "Apolar", 1.61},
{198, 1, "Polar", 1.42}, {199, 0, "Apolar", 1.88},
{200, 0, "Apolar", 1.88}, {201, 0, "Apolar", 1.88},
{202, 1, "Polar", 1.64}, {203, 0, "Apolar", 1.88},
{204, 0, "Apolar", 1.61}, {205, 1, "Polar", 1.42},
{206, 0, "Apolar", 1.88}, {207, 0, "Apolar", 1.88},
{208, 0, "Apolar", 1.88}, {209, 0, "Apolar", 1.88},
{210, 1, "Polar", 1.64}, {211, 1, "Polar", 1.64},
{212, 0, "Apolar", 1.88}, {213, 0, "Apolar", 1.61},
{214, 1, "Polar", 1.42}, {215, 0, "Apolar", 1.88},
{216, 1, "Polar", 1.64}, {217, 0, "Apolar", 1.88},
{218, 0, "Apolar", 1.61}, {219, 1, "Polar", 1.42},
{220, 0, "Apolar", 1.88}, {221, 0, "Apolar", 1.88},
{222, 0, "Apolar", 1.88}, {223, 0, "Apolar", 1.88},
{224, 1, "Polar", 1.64}, {225, 1, "Polar", 1.64},
{226, 0, "Apolar", 1.88}, {227, 0, "Apolar", 1.61},
{228, 1, "Polar", 1.42}, {229, 0, "Apolar", 1.88},
{230, 0, "Apolar", 1.88}, {231, 0, "Apolar", 1.88},
{232, 0, "Apolar", 1.88}, {233, 1, "Polar", 1.64},
{234, 0, "Apolar", 1.88}, {235, 0, "Apolar", 1.61},
{236, 1, "Polar", 1.42}, {237, 0, "Apolar", 1.88},
{238, 0, "Apolar", 1.88}, {239, 0, "Apolar", 1.61},
{240, 1, "Polar", 1.42}, {241, 1, "Polar", 1.64},
{242, 1, "Polar", 1.64}, {243, 0, "Apolar", 1.88},
{244, 0, "Apolar", 1.61}, {245, 1, "Polar", 1.42},
{246, 0, "Apolar", 1.88}, {247, 0, "Apolar", 1.61},
{248, 1, "Polar", 1.42}, {249, 1, "Polar", 1.46},
{250, 1, "Polar", 1.64}, {251, 0, "Apolar", 1.88},
{252, 0, "Apolar", 1.61}, {253, 1, "Polar", 1.42},
{254, 0, "Apolar", 1.88}, {255, 0, "Apolar", 1.88},
{256, 0, "Apolar", 1.88}, {257, 0, "Apolar", 1.88},
{258, 1, "Polar", 1.64}, {259, 1, "Polar", 1.64},
{260, 0, "Apolar", 1.88}, {261, 0, "Apolar", 1.61},
{262, 1, "Polar", 1.42}, {263, 0, "Apolar", 1.88},
{264, 0, "Apolar", 1.88}, {265, 0, "Apolar", 1.61},
{266, 1, "Polar", 1.42}, {267, 1, "Polar", 1.46},
{268, 1, "Polar", 1.64}, {269, 0, "Apolar", 1.88},
{270, 0, "Apolar", 1.61}, {271, 1, "Polar", 1.42},
{272, 1, "Polar", 1.64}, {273, 0, "Apolar", 1.88},
{274, 0, "Apolar", 1.61}, {275, 1, "Polar", 1.42},
{276, 0, "Apolar", 1.88}, {277, 0, "Apolar", 1.88},
{278, 0, "Apolar", 1.88}, {279, 0, "Apolar", 1.88},
{280, 1, "Polar", 1.64}, {281, 0, "Apolar", 1.88},
{282, 0, "Apolar", 1.61}, {283, 1, "Polar", 1.42},
{284, 0, "Apolar", 1.88}, {285, 0, "Apolar", 1.88},
{286, 0, "Apolar", 1.88}, {287, 1, "Polar", 1.64},
{288, 0, "Apolar", 1.88}, {289, 0, "Apolar", 1.61},
{290, 1, "Polar", 1.42}, {291, 0, "Apolar", 1.88},
{292, 0, "Apolar", 1.88}, {293, 0, "Apolar", 1.88},
{294, 1, "Polar", 1.64}, {295, 0, "Apolar", 1.88},
{296, 0, "Apolar", 1.61}, {297, 1, "Polar", 1.42},
{298, 0, "Apolar", 1.88}, {299, 0, "Apolar", 1.61},
{300, 1, "Polar", 1.42}, {301, 1, "Polar", 1.46},
{302, 1, "Polar", 1.64}, {303, 0, "Apolar", 1.88},
{304, 0, "Apolar", 1.61}, {305, 1, "Polar", 1.42},
{306, 0, "Apolar", 1.88}, {307, 0, "Apolar", 1.88},
{308, 0, "Apolar", 1.61}, {309, 1, "Polar", 1.42},
{310, 1, "Polar", 1.64}, {311, 1, "Polar", 1.64},
{312, 0, "Apolar", 1.88}, {313, 0, "Apolar", 1.61},
{314, 1, "Polar", 1.42}, {315, 0, "Apolar", 1.88},
{316, 0, "Apolar", 1.88}, {317, 0, "Apolar", 1.61},
{318, 1, "Polar", 1.42}, {319, 1, "Polar", 1.64},
{320, 1, "Polar", 1.64}, {321, 0, "Apolar", 1.88},
{322, 0, "Apolar", 1.61}, {323, 1, "Polar", 1.42},
{324, 0, "Apolar", 1.88}, {325, 0, "Apolar", 1.88},
{326, 0, "Apolar", 1.88}, {327, 1, "Polar", 1.64},
{328, 0, "Apolar", 1.61}, {329, 1, "Polar", 1.64},
{330, 1, "Polar", 1.64}, {331, 1, "Polar", 1.64},
{332, 0, "Apolar", 1.88}, {333, 0, "Apolar", 1.61},
{334, 1, "Polar", 1.42}, {335, 0, "Apolar", 1.88},
{336, 0, "Apolar", 1.88}, {337, 0, "Apolar", 1.88},
{338, 0, "Apolar", 1.88}, {339, 1, "Polar", 1.64},
{340, 0, "Apolar", 1.88}, {341, 0, "Apolar", 1.61},
{342, 1, "Polar", 1.42}, {343, 0, "Apolar", 1.88},
{344, 0, "Apolar", 1.88}, {345, 0, "Apolar", 1.88},
{346, 0, "Apolar", 1.88}, {347, 1, "Polar", 1.64},
{348, 0, "Apolar", 1.88}, {349, 0, "Apolar", 1.61},
{350, 1, "Polar", 1.42}, {351, 0, "Apolar", 1.88},
{352, 0, "Apolar", 1.61}, {353, 0, "Apolar", 1.76},
{354, 0, "Apolar", 1.76}, {355, 0, "Apolar", 1.76},
{356, 0, "Apolar", 1.76}, {357, 0, "Apolar", 1.76},
{358, 1, "Polar", 1.64}, {359, 0, "Apolar", 1.88},
{360, 0, "Apolar", 1.61}, {361, 1, "Polar", 1.42},
{362, 0, "Apolar", 1.88}, {363, 1, "Polar", 1.64},
{364, 0, "Apolar", 1.88}, {365, 0, "Apolar", 1.61},
{366, 1, "Polar", 1.42}, {367, 1, "Polar", 1.64},
{368, 0, "Apolar", 1.88}, {369, 0, "Apolar", 1.61},
{370, 1, "Polar", 1.42}, {371, 0, "Apolar", 1.88},
{372, 0, "Apolar", 1.88}, {373, 0, "Apolar", 1.88},
{374, 0, "Apolar", 1.88}, {375, 1, "Polar", 1.64},
{376, 1, "Polar", 1.64}, {377, 0, "Apolar", 1.88},
{378, 0, "Apolar", 1.61}, {379, 1, "Polar", 1.42},
{380, 0, "Apolar", 1.88}, {381, 0, "Apolar", 1.88},
{382, 0, "Apolar", 1.61}, {383, 1, "Polar", 1.42},
{384, 1, "Polar", 1.64}, {385, 1, "Polar", 1.64},
{386, 0, "Apolar", 1.88}, {387, 0, "Apolar", 1.61},
{388, 1, "Polar", 1.42}, {389, 0, "Apolar", 1.88},
{390, 0, "Apolar", 1.88}, {391, 0, "Apolar", 1.88},
{392, 0, "Apolar", 1.88}, {393, 1, "Polar", 1.64},
{394, 0, "Apolar", 1.88}, {395, 0, "Apolar", 1.61},
{396, 1, "Polar", 1.42}, {397, 0, "Apolar", 1.88},
{398, 0, "Apolar", 1.88}, {399, 0, "Apolar", 1.61},
{400, 1, "Polar", 1.42}, {401, 1, "Polar", 1.46},
{402, 1, "Polar", 1.64}, {403, 0, "Apolar", 1.88},
{404, 0, "Apolar", 1.61}, {405, 1, "Polar", 1.42},
{406, 0, "Apolar", 1.88}, {407, 0, "Apolar", 1.61},
{408, 1, "Polar", 1.42}, {409, 1, "Polar", 1.46},
{410, 1, "Polar", 1.64}, {411, 0, "Apolar", 1.88},
{412, 0, "Apolar", 1.61}, {413, 1, "Polar", 1.42},
{414, 1, "Polar", 1.64}, {415, 0, "Apolar", 1.88},
{416, 0, "Apolar", 1.61}, {417, 1, "Polar", 1.42},
{418, 0, "Apolar", 1.88}, {419, 0, "Apolar", 1.88},
{420, 0, "Apolar", 1.88}, {421, 1, "Polar", 1.64},
{422, 0, "Apolar", 1.61}, {423, 1, "Polar", 1.64},
{424, 1, "Polar", 1.64}, {425, 1, "Polar", 1.64},
{426, 0, "Apolar", 1.88}, {427, 0, "Apolar", 1.61},
{428, 1, "Polar", 1.42}, {429, 0, "Apolar", 1.88},
{430, 1, "Polar", 1.46}, {431, 0, "Apolar", 1.88},
{432, 1, "Polar", 1.64}, {433, 0, "Apolar", 1.88},
{434, 0, "Apolar", 1.61}, {435, 1, "Polar", 1.42},
{436, 0, "Apolar", 1.88}, {437, 0, "Apolar", 1.88},
{438, 0, "Apolar", 1.88}, {439, 0, "Apolar", 1.88},
{440, 1, "Polar", 1.64}, {441, 0, "Apolar", 1.88},
{442, 0, "Apolar", 1.61}, {443, 1, "Polar", 1.42},
{444, 0, "Apolar", 1.88}, {445, 1, "Polar", 1.46},
{446, 1, "Polar", 1.64}, {447, 0, "Apolar", 1.88},
{448, 0, "Apolar", 1.61}, {449, 1, "Polar", 1.42},
{450, 0, "Apolar", 1.88}, {451, 0, "Apolar", 1.61},
{452, 1, "Polar", 1.42}, {453, 1, "Polar", 1.46},
{454, 1, "Polar", 1.64}, {455, 0, "Apolar", 1.88},
{456, 0, "Apolar", 1.61}, {457, 1, "Polar", 1.42},
{458, 0, "Apolar", 1.88}, {459, 0, "Apolar", 1.61},
{460, 0, "Apolar", 1.76}, {461, 0, "Apolar", 1.76},
{462, 0, "Apolar", 1.76}, {463, 0, "Apolar", 1.76},
{464, 0, "Apolar", 1.61}, {465, 1, "Polar", 1.46},
{466, 1, "Polar", 1.64}, {467, 0, "Apolar", 1.88},
{468, 0, "Apolar", 1.61}, {469, 1, "Polar", 1.42},
{470, 0, "Apolar", 1.88}, {471, 0, "Apolar", 1.61},
{472, 1, "Polar", 1.42}, {473, 1, "Polar", 1.64},
{474, 1, "Polar", 1.64}, {475, 0, "Apolar", 1.88},
{476, 0, "Apolar", 1.61}, {477, 1, "Polar", 1.42},
{478, 0, "Apolar", 1.88}, {479, 0, "Apolar", 1.88},
{480, 0, "Apolar", 1.88}, {481, 0, "Apolar", 1.88},
{482, 1, "Polar", 1.64}, {483, 0, "Apolar", 1.88},
{484, 0, "Apolar", 1.61}, {485, 1, "Polar", 1.42},
{486, 0, "Apolar", 1.88}, {487, 0, "Apolar", 1.88},
{488, 0, "Apolar", 1.61}, {489, 1, "Polar", 1.42},
{490, 1, "Polar", 1.64}, {491, 1, "Polar", 1.64},
{492, 0, "Apolar", 1.88}, {493, 0, "Apolar", 1.61},
{494, 1, "Polar", 1.42}, {495, 0, "Apolar", 1.88},
{496, 0, "Apolar", 1.88}, {497, 0, "Apolar", 1.88},
{498, 0, "Apolar", 1.88}, {499, 1, "Polar", 1.64},
{500, 1, "Polar", 1.64}, {501, 0, "Apolar", 1.88},
{502, 0, "Apolar", 1.61}, {503, 1, "Polar", 1.42},
{504, 0, "Apolar", 1.88}, {505, 0, "Apolar", 1.88},
{506, 0, "Apolar", 1.61}, {507, 1, "Polar", 1.42},
{508, 1, "Polar", 1.46}, {509, 1, "Polar", 1.64},
{510, 0, "Apolar", 1.88}, {511, 0, "Apolar", 1.61},
{512, 1, "Polar", 1.42}, {513, 0, "Apolar", 1.88},
{514, 1, "Polar", 1.46}, {515, 1, "Polar", 1.64},
{516, 0, "Apolar", 1.88}, {517, 0, "Apolar", 1.61},
{518, 1, "Polar", 1.42}, {519, 0, "Apolar", 1.88},
{520, 1, "Polar", 1.46}, {521, 0, "Apolar", 1.88},
{522, 1, "Polar", 1.64}, {523, 0, "Apolar", 1.88},
{524, 0, "Apolar", 1.61}, {525, 1, "Polar", 1.42},
{526, 0, "Apolar", 1.88}, {527, 0, "Apolar", 1.88},
{528, 0, "Apolar", 1.88}, {529, 0, "Apolar", 1.88},
{530, 1, "Polar", 1.64}, {531, 0, "Apolar", 1.88},
{532, 0, "Apolar", 1.61}, {533, 1, "Polar", 1.42},
{534, 0, "Apolar", 1.88}, {535, 0, "Apolar", 1.61},
{536, 1, "Polar", 1.64}, {537, 0, "Apolar", 1.76},
{538, 0, "Apolar", 1.76}, {539, 1, "Polar", 1.64},
{540, 1, "Polar", 1.64}, {541, 0, "Apolar", 1.88},
{542, 0, "Apolar", 1.61}, {543, 1, "Polar", 1.42},
{544, 0, "Apolar", 1.88}, {545, 0, "Apolar", 1.88},
{546, 0, "Apolar", 1.88}, {547, 0, "Apolar", 1.88},
{548, 1, "Polar", 1.64}, {549, 0, "Apolar", 1.88},
{550, 0, "Apolar", 1.61}, {551, 1, "Polar", 1.42},
{552, 0, "Apolar", 1.88}, {553, 0, "Apolar", 1.88},
{554, 0, "Apolar", 1.88}, {555, 1, "Polar", 1.64},
{556, 0, "Apolar", 1.88}, {557, 0, "Apolar", 1.61},
{558, 1, "Polar", 1.42}, {559, 0, "Apolar", 1.88},
{560, 0, "Apolar", 1.88}, {561, 0, "Apolar", 1.88},
{562, 0, "Apolar", 1.88}, {563, 1, "Polar", 1.64},
{564, 0, "Apolar", 1.88}, {565, 0, "Apolar", 1.61},
{566, 1, "Polar", 1.42}, {567, 0, "Apolar", 1.88},
{568, 0, "Apolar", 1.88}, {569, 0, "Apolar", 1.88},
{570, 1, "Polar", 1.64}, {571, 0, "Apolar", 1.61},
{572, 1, "Polar", 1.64}, {573, 1, "Polar", 1.64},
{574, 1, "Polar", 1.64}, {575, 0, "Apolar", 1.88},
{576, 0, "Apolar", 1.61}, {577, 1, "Polar", 1.42},
{578, 0, "Apolar", 1.88}, {579, 0, "Apolar", 1.88},
{580, 0, "Apolar", 1.88}, {581, 0, "Apolar", 1.88},
{582, 1, "Polar", 1.64}, {583, 0, "Apolar", 1.88},
{584, 0, "Apolar", 1.61}, {585, 1, "Polar", 1.42},
{586, 0, "Apolar", 1.88}, {587, 0, "Apolar", 1.88},
{588, 0, "Apolar", 1.88}, {589, 1, "Polar", 1.64},
{590, 0, "Apolar", 1.61}, {591, 1, "Polar", 1.64},
{592, 1, "Polar", 1.64}, {593, 1, "Polar", 1.64},
{594, 0, "Apolar", 1.88}, {595, 0, "Apolar", 1.61},
{596, 1, "Polar", 1.42}, {597, 1, "Polar", 1.64},
{598, 0, "Apolar", 1.88}, {599, 0, "Apolar", 1.61},
{600, 1, "Polar", 1.42}, {601, 1, "Polar", 1.46}};
void testPDB() {
BOOST_LOG(rdInfoLog) << "-----------------------\n Testing FreeSASA basics"
<< std::endl;
std::string rdbase = getenv("RDBASE");
std::string fName = rdbase +=
"/External/FreeSASA/freesasa-master/tests/data/1d3z.pdb";
ROMol *m;
{
const bool sanitize=true;
const bool removeHs=true;
m = PDBFileToMol(fName, sanitize, removeHs);
}
std::vector<double> radii;
FreeSASA::classifyAtoms(*m, radii);
for (ROMol::AtomIterator at = m->beginAtoms(); at != m->endAtoms(); ++at) {
Atom *atom = (*at);
unsigned int idx = atom->getIdx();
TEST_ASSERT(idx == ExpectedProtor1d3z[idx].idx);
TEST_ASSERT(atom->getProp<int>(common_properties::Atom::SASAClass) ==
ExpectedProtor1d3z[idx].cls);
TEST_ASSERT(atom->getProp<std::string>(common_properties::Atom::SASAClassName) ==
ExpectedProtor1d3z[idx].clsname);
TEST_ASSERT(radii[idx] == ExpectedProtor1d3z[idx].radius);
}
FreeSASA::SASAOpts opts;
opts.algorithm = FreeSASA::SASAOpts::ShrakeRupley;
double sasa = FreeSASA::calcSASA(*m, radii, -1, NULL, opts);
TEST_ASSERT(fabs(sasa - 5000.340175) < 1e-5);
delete m;
{
const bool sanitize=false;
const bool removeHs=false;
m = PDBFileToMol(fName, sanitize, removeHs);
}
ROMol *mnoh = MolOps::removeHs(*m);
FreeSASA::classifyAtoms(*mnoh, radii);
sasa = FreeSASA::calcSASA(*mnoh, radii, -1, NULL, opts);
TEST_ASSERT(fabs(sasa - 5000.340175) < 1e-5);
const QueryAtom *apolar = FreeSASA::makeFreeSasaAPolarAtomQuery();
const QueryAtom *polar = FreeSASA::makeFreeSasaPolarAtomQuery();
double apolard = FreeSASA::calcSASA(*mnoh, radii, -1, apolar, opts);
double polard = FreeSASA::calcSASA(*mnoh, radii, -1, polar, opts);
std::cerr << " polar " << polard << std::endl;
std::cerr << " apolar " << apolard << std::endl;
TEST_ASSERT(fabs(polard + apolard - 5000.340175) < 1e-5);
delete m;
delete mnoh;
BOOST_LOG(rdInfoLog) << "Done" << std::endl;
}
int main() {
RDLog::InitLogs();
testPDB();
}