mirror of
https://github.com/rdkit/rdkit.git
synced 2026-06-03 21:44:30 +08:00
* Fixes #4535 First pass, not sure what the best fields are here * update output format
This commit is contained in:
@@ -7,7 +7,7 @@ rdkit_library(GraphMol
|
||||
MolDiscriminators.cpp ConjugHybrid.cpp AddHs.cpp
|
||||
Matrices.cpp Chirality.cpp RingInfo.cpp Conformer.cpp
|
||||
Renumber.cpp AdjustQuery.cpp Resonance.cpp StereoGroup.cpp
|
||||
new_canon.cpp SubstanceGroup.cpp FindStereo.cpp
|
||||
new_canon.cpp SubstanceGroup.cpp FindStereo.cpp MonomerInfo.cpp
|
||||
SHARED
|
||||
LINK_LIBRARIES RDGeometryLib RDGeneral )
|
||||
target_compile_definitions(GraphMol PRIVATE RDKIT_GRAPHMOL_BUILD)
|
||||
|
||||
21
Code/GraphMol/MonomerInfo.cpp
Normal file
21
Code/GraphMol/MonomerInfo.cpp
Normal file
@@ -0,0 +1,21 @@
|
||||
//
|
||||
// Copyright (C) 2021 Greg Landrum and other RDKit contributors
|
||||
//
|
||||
// @@ All Rights Reserved @@
|
||||
// This file is part of the RDKit.
|
||||
// The contents are covered by the terms of the BSD license
|
||||
// which is included in the file license.txt, found at the root
|
||||
// of the RDKit source tree.
|
||||
//
|
||||
#include <iostream>
|
||||
#include "MonomerInfo.h"
|
||||
|
||||
using namespace RDKit;
|
||||
|
||||
//! allows AtomPDBResidueInfo objects to be dumped to streams
|
||||
std::ostream &operator<<(std::ostream &target, const AtomPDBResidueInfo &apri) {
|
||||
target << apri.getSerialNumber() << " " << apri.getName() << " "
|
||||
<< apri.getResidueName() << " " << apri.getChainId() << " "
|
||||
<< apri.getResidueNumber();
|
||||
return target;
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// Copyright (C) 2013 Greg Landrum
|
||||
// Copyright (C) 2013-2021 Greg Landrum and other RDKit contributors
|
||||
//
|
||||
// @@ All Rights Reserved @@
|
||||
// This file is part of the RDKit.
|
||||
@@ -13,8 +13,8 @@
|
||||
|
||||
*/
|
||||
#include <RDGeneral/export.h>
|
||||
#ifndef _RD_MONOMERINFO_H
|
||||
#define _RD_MONOMERINFO_H
|
||||
#ifndef RD_MONOMERINFO_H
|
||||
#define RD_MONOMERINFO_H
|
||||
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
@@ -14,7 +14,9 @@
|
||||
#include <GraphMol/new_canon.h>
|
||||
#include <GraphMol/RDKitQueries.h>
|
||||
#include <GraphMol/Chirality.h>
|
||||
#include <GraphMol/MonomerInfo.h>
|
||||
#include <GraphMol/FileParsers/FileParsers.h>
|
||||
#include <GraphMol/FileParsers/SequenceParsers.h>
|
||||
#include <GraphMol/SmilesParse/SmilesParse.h>
|
||||
#include <GraphMol/SmilesParse/SmilesWrite.h>
|
||||
#include <GraphMol/SmilesParse/SmartsWrite.h>
|
||||
@@ -2434,4 +2436,27 @@ TEST_CASE("KekulizeIfPossible") {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("Github #4535: operator<< for AtomPDBResidue", "[PDB]") {
|
||||
SECTION("basics") {
|
||||
bool sanitize = true;
|
||||
int flavor = 0;
|
||||
std::unique_ptr<RWMol> mol(SequenceToMol("KY", sanitize, flavor));
|
||||
REQUIRE(mol);
|
||||
REQUIRE(mol->getAtomWithIdx(0)->getMonomerInfo());
|
||||
auto res = static_cast<AtomPDBResidueInfo *>(
|
||||
mol->getAtomWithIdx(0)->getMonomerInfo());
|
||||
REQUIRE(res);
|
||||
std::stringstream oss;
|
||||
oss << *res << std::endl;
|
||||
res = static_cast<AtomPDBResidueInfo *>(
|
||||
mol->getAtomWithIdx(mol->getNumAtoms() - 1)->getMonomerInfo());
|
||||
REQUIRE(res);
|
||||
oss << *res << std::endl;
|
||||
auto tgt = R"FOO(1 N LYS A 1
|
||||
22 OXT TYR A 2
|
||||
)FOO";
|
||||
CHECK(oss.str() == tgt);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user