// Copyright 2017 Global Phasing Ltd. #include "common.h" #include #include #include #include "gemmi/seqid.hpp" #include "gemmi/metadata.hpp" #include "gemmi/enumstr.hpp" #include "gemmi/tostr.hpp" #include "meta.h" namespace py = pybind11; using namespace gemmi; namespace gemmi { // not inline std::ostream& operator<< (std::ostream& os, const Entity& ent) { os << "'; return os; } } void add_meta(py::module& m) { // seqid.hpp py::class_(m, "SeqId") .def(py::init()) .def(py::init()) .def_readwrite("num", &SeqId::num) .def_readwrite("icode", &SeqId::icode) .def("__str__", &SeqId::str) .def("__repr__", [](const SeqId& self) { return ""; }); py::class_(m, "ResidueId") .def(py::init<>()) .def_readwrite("name", &ResidueId::name) .def_readwrite("seqid", &ResidueId::seqid) .def_readwrite("segment", &ResidueId::segment) .def("__str__", &ResidueId::str) .def("__repr__", [](const ResidueId& self) { return ""; }); py::class_(m, "AtomAddress") .def(py::init<>()) .def(py::init(), py::arg("chain"), py::arg("seqid"), py::arg("resname"), py::arg("atom"), py::arg("altloc")='\0') .def_readwrite("chain_name", &AtomAddress::chain_name) .def_readwrite("res_id", &AtomAddress::res_id) .def_readwrite("atom_name", &AtomAddress::atom_name) .def_readwrite("altloc", &AtomAddress::altloc) .def("__str__", &AtomAddress::str) .def("__repr__", [](const AtomAddress& self) { return tostr("'); }); // metadata.hpp py::class_(m, "NcsOp") .def(py::init<>()) .def(py::init([](const Transform& tr, const std::string& id, bool given) { NcsOp* op = new NcsOp(); op->tr = tr; op->id = id; op->given = given; return op; }), py::arg("tr"), py::arg("id")="", py::arg("given")=false) .def_readwrite("id", &NcsOp::id) .def_readwrite("given", &NcsOp::given) .def_readonly("tr", &NcsOp::tr) .def("apply", &NcsOp::apply) .def("__repr__", [](const NcsOp& self) { return tostr(""); }); py::enum_(m, "EntityType") .value("Unknown", EntityType::Unknown) .value("Polymer", EntityType::Polymer) .value("NonPolymer", EntityType::NonPolymer) .value("Water", EntityType::Water); py::enum_(m, "PolymerType") .value("PeptideL", PolymerType::PeptideL) .value("PeptideD", PolymerType::PeptideD) .value("Dna", PolymerType::Dna) .value("Rna", PolymerType::Rna) .value("DnaRnaHybrid", PolymerType::DnaRnaHybrid) .value("SaccharideD", PolymerType::SaccharideD) .value("SaccharideL", PolymerType::SaccharideL) .value("Pna", PolymerType::Pna) .value("CyclicPseudoPeptide", PolymerType::CyclicPseudoPeptide) .value("Other", PolymerType::Other) .value("Unknown", PolymerType::Unknown); py::class_(m, "Entity") .def(py::init()) .def_readwrite("name", &Entity::name) .def_readwrite("subchains", &Entity::subchains) .def_readwrite("entity_type", &Entity::entity_type) .def_readwrite("polymer_type", &Entity::polymer_type) .def_readwrite("full_sequence", &Entity::full_sequence) .def_static("first_mon", &Entity::first_mon) .def("__repr__", [](const Entity& self) { return tostr(self); }); py::enum_(m, "ConnectionType") .value("Covale", Connection::Type::Covale) .value("Disulf", Connection::Type::Disulf) .value("Hydrog", Connection::Type::Hydrog) .value("MetalC", Connection::Type::MetalC) .value("Unknown", Connection::Type::Unknown); py::class_(m, "Connection") .def(py::init<>()) .def_readwrite("name", &Connection::name) .def_readwrite("link_id", &Connection::link_id) .def_readwrite("type", &Connection::type) .def_readwrite("asu", &Connection::asu) .def_readwrite("partner1", &Connection::partner1) .def_readwrite("partner2", &Connection::partner2) .def_readwrite("reported_distance", &Connection::reported_distance) .def("__repr__", [](const Connection& self) { return tostr("'); }); py::class_ assembly(m, "Assembly"); py::class_(assembly, "Operator") .def(py::init<>()) .def_readonly("name", &Assembly::Operator::name) .def_readonly("type", &Assembly::Operator::type) .def_readonly("transform", &Assembly::Operator::transform); py::bind_vector>(assembly, "OperatorList"); py::class_(assembly, "Gen") .def(py::init<>()) .def_readonly("chains", &Assembly::Gen::chains) .def_readonly("subchains", &Assembly::Gen::subchains) .def_readonly("operators", &Assembly::Gen::operators); py::bind_vector>(assembly, "GenList"); assembly .def_readonly("name", &Assembly::name) .def_readonly("oligomeric_details", &Assembly::oligomeric_details) .def_readonly("generators", &Assembly::generators) ; py::bind_vector>(m, "AssemblyList"); }