Skip to content

Commit

Permalink
api: added atom hybridization calculation (#751)
Browse files Browse the repository at this point in the history
  • Loading branch information
mkviatkovskii authored Jun 1, 2022
1 parent 7788786 commit 2abfb8a
Show file tree
Hide file tree
Showing 40 changed files with 1,152 additions and 365 deletions.
11 changes: 11 additions & 0 deletions api/c/indigo/indigo.h
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,17 @@ CEXPORT int indigoAtomicNumber(int atom);
CEXPORT int indigoIsotope(int atom);
// Not applicable to query molecules.
CEXPORT int indigoValence(int atom);
// Return atom hybridization
// S = 1,
// SP = 2,
// SP2 = 3,
// SP3 = 4,
// SP3D = 5,
// SP3D2 = 6,
// SP3D3 = 7,
// SP3D4 = 8,
// SP2D = 9
CEXPORT int indigoGetHybridization(int atom);
// Returns zero if valence of the atom is wrong
CEXPORT int indigoCheckValence(int atom);

Expand Down
12 changes: 12 additions & 0 deletions api/c/indigo/src/indigo_molecule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include "indigo_mapping.h"
#include "molecule/canonical_smiles_saver.h"
#include "molecule/elements.h"
#include "molecule/hybridization.h"
#include "molecule/molecule_auto_loader.h"
#include "molecule/molecule_automorphism_search.h"
#include "molecule/molecule_fingerprint.h"
Expand Down Expand Up @@ -1271,6 +1272,17 @@ CEXPORT int indigoValence(int atom)
INDIGO_END(-1);
}

CEXPORT int indigoGetHybridization(int atom)
{
INDIGO_BEGIN
{
IndigoAtom& ia = IndigoAtom::cast(self.getObject(atom));
auto& molecule = ia.mol.asMolecule();
return static_cast<int>(HybridizationCalculator::calculate(molecule, ia.idx));
}
INDIGO_END(-1);
}

CEXPORT int indigoCheckValence(int atom)
{
INDIGO_BEGIN
Expand Down
18 changes: 18 additions & 0 deletions api/cpp/src/BingoNoSQL.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
/****************************************************************************
* Copyright (C) from 2009 to Present EPAM Systems.
*
* This file is part of Indigo toolkit.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
***************************************************************************/

#include "BingoNoSQL.h"

#include <bingo-nosql.h>
Expand Down
18 changes: 18 additions & 0 deletions api/cpp/src/BingoNoSQL.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
/****************************************************************************
* Copyright (C) from 2009 to Present EPAM Systems.
*
* This file is part of Indigo toolkit.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
***************************************************************************/

#pragma once

#include "BingoResultIterator.h"
Expand Down
18 changes: 18 additions & 0 deletions api/cpp/src/BingoResult.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
/****************************************************************************
* Copyright (C) from 2009 to Present EPAM Systems.
*
* This file is part of Indigo toolkit.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
***************************************************************************/

#include <bingo-nosql.h>

#include "BingoResult.h"
Expand Down
18 changes: 18 additions & 0 deletions api/cpp/src/BingoResult.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
/****************************************************************************
* Copyright (C) from 2009 to Present EPAM Systems.
*
* This file is part of Indigo toolkit.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
***************************************************************************/

#pragma once

#include "IndigoSession.h"
Expand Down
18 changes: 18 additions & 0 deletions api/cpp/src/BingoResultIterator.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
/****************************************************************************
* Copyright (C) from 2009 to Present EPAM Systems.
*
* This file is part of Indigo toolkit.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
***************************************************************************/

#include "BingoResultIterator.h"

#include <bingo-nosql.h>
Expand Down
18 changes: 18 additions & 0 deletions api/cpp/src/BingoResultIterator.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
/****************************************************************************
* Copyright (C) from 2009 to Present EPAM Systems.
*
* This file is part of Indigo toolkit.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
***************************************************************************/

#pragma once

#include "IndigoSession.h"
Expand Down
34 changes: 34 additions & 0 deletions api/cpp/src/IndigoAtom.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/****************************************************************************
* Copyright (C) from 2009 to Present EPAM Systems.
*
* This file is part of Indigo toolkit.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
***************************************************************************/

#include "IndigoAtom.h"

#include <indigo.h>

namespace indigo_cpp
{
IndigoAtom::IndigoAtom(int id, IndigoSessionPtr session) : IndigoObject(id, std::move(session))
{
}

Hybridization IndigoAtom::getHybridization() const
{
session()->setSessionId();
return Hybridization(session()->_checkResult(indigoGetHybridization(id())));
}
}
45 changes: 45 additions & 0 deletions api/cpp/src/IndigoAtom.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/****************************************************************************
* Copyright (C) from 2009 to Present EPAM Systems.
*
* This file is part of Indigo toolkit.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
***************************************************************************/

#pragma once

#include "IndigoObject.h"

namespace indigo_cpp
{
enum class Hybridization
{
S = 1,
SP = 2,
SP2 = 3,
SP3 = 4,
SP3D = 5,
SP3D2 = 6,
SP3D3 = 7,
SP3D4 = 8,
SP2D = 9
};

class IndigoAtom : public IndigoObject
{
public:
explicit IndigoAtom(int id, IndigoSessionPtr session);

Hybridization getHybridization() const;
};
}
6 changes: 6 additions & 0 deletions api/cpp/src/IndigoBaseMolecule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,9 @@ std::string IndigoBaseMolecule::ctfile() const
{
return molfile();
}

IndigoAtom IndigoBaseMolecule::getAtom(int atomIndex) const
{
session()->setSessionId();
return IndigoAtom(session()->_checkResult(indigoGetAtom(id(), atomIndex)), session());
}
3 changes: 3 additions & 0 deletions api/cpp/src/IndigoBaseMolecule.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

#pragma once

#include "IndigoAtom.h"
#include "IndigoChemicalStructure.h"

namespace indigo_cpp
Expand All @@ -35,5 +36,7 @@ namespace indigo_cpp
public:
std::string molfile() const;
std::string ctfile() const override;

IndigoAtom getAtom(int atomIndex) const;
};
}
18 changes: 18 additions & 0 deletions api/cpp/src/IndigoCopyableObject.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
/****************************************************************************
* Copyright (C) from 2009 to Present EPAM Systems.
*
* This file is part of Indigo toolkit.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
***************************************************************************/

#include "IndigoCopyableObject.h"

#include <indigo.h>
Expand Down
18 changes: 18 additions & 0 deletions api/cpp/src/IndigoCopyableObject.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
/****************************************************************************
* Copyright (C) from 2009 to Present EPAM Systems.
*
* This file is part of Indigo toolkit.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
***************************************************************************/

#pragma once

#include "IndigoObject.h"
Expand Down
7 changes: 7 additions & 0 deletions api/cpp/src/IndigoMolecule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,35 +34,42 @@ IndigoMolecule::IndigoMolecule(const IndigoMolecule& other) : IndigoBaseMolecule

double IndigoMolecule::molecularWeight() const
{
session()->setSessionId();
return session()->_checkResultFloat(indigoMolecularWeight(id()));
}

double IndigoMolecule::tpsa(const bool includeSP) const
{
session()->setSessionId();
return session()->_checkResultFloat(indigoTPSA(id(), static_cast<int>(includeSP)));
}

int IndigoMolecule::numRotatableBonds() const
{
session()->setSessionId();
return session()->_checkResult(indigoNumRotatableBonds(id()));
}

int IndigoMolecule::numHydrogenBondAcceptors() const
{
session()->setSessionId();
return session()->_checkResult(indigoNumHydrogenBondAcceptors(id()));
}

int IndigoMolecule::numHydrogenBondDonors() const
{
session()->setSessionId();
return session()->_checkResult(indigoNumHydrogenBondDonors(id()));
}

double IndigoMolecule::cLogP() const
{
session()->setSessionId();
return session()->_checkResultFloat(indigoCLogP(id()));
}

double IndigoMolecule::cMolarRefractivity() const
{
session()->setSessionId();
return session()->_checkResultFloat(indigoCMolarRefractivity(id()));
}
18 changes: 18 additions & 0 deletions api/cpp/src/IndigoRDFileIterator.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
/****************************************************************************
* Copyright (C) from 2009 to Present EPAM Systems.
*
* This file is part of Indigo toolkit.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
***************************************************************************/

#include "IndigoRDFileIterator.h"

#include <indigo.h>
Expand Down
Loading

0 comments on commit 2abfb8a

Please sign in to comment.