-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* preliminary commit, trivial read program compiles * specify mmcif format * I can read the various pieces * all atom properties except bonds work * added comments re mass and atomic number * minimal mmcif implementation * fixed compilation problem * basic tests passed * added setting mass (changed AtomicGroup as well) * missed whitespace change in merge * updatery
- Loading branch information
1 parent
5e5c5d2
commit 0dd43ca
Showing
16 changed files
with
300 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
|
||
#include <loos.hpp> | ||
#include <gemmi/mmread.hpp> | ||
#include <gemmi/cif.hpp> | ||
#include <gemmi/mmcif.hpp> // cif::Document -> Structure | ||
#include <gemmi/gz.hpp> | ||
|
||
namespace cif = gemmi::cif; | ||
|
||
|
||
int main(int argc, char *argv[]) { | ||
std::string filename = std::string(argv[1]); | ||
|
||
loos::AtomicGroup ag; | ||
|
||
auto structure = gemmi::read_structure_file(filename, gemmi::CoorFormat::Mmcif); | ||
auto unit_cell = structure.cell; | ||
auto box = loos::GCoord(unit_cell.a, unit_cell.b, unit_cell.c); | ||
ag.periodicBox(box); | ||
|
||
// TODO: hard-wired to read first model, but there should probably be a way to read others | ||
auto model = structure.first_model(); | ||
int atom_index = 0; | ||
int residue_number = 1; | ||
for (auto chain:model.chains) { | ||
std::string chain_name = chain.name; | ||
for (auto residue:chain.residues) { | ||
std::string residue_name = residue.name; | ||
auto label_seq = residue.label_seq; | ||
std::string res_entity_id = residue.entity_id; | ||
std::cout << "Residue: " | ||
<< residue_number << "\t" | ||
<< label_seq.str() << "\t" | ||
<< res_entity_id << "\t" | ||
<< residue.name << "\t" | ||
<< residue.seqid.num.value << "\t" | ||
<< std::endl; | ||
for (auto atom:residue.atoms) { | ||
loos::pAtom pa(new loos::Atom); | ||
pa->index(atom.serial); | ||
pa->id(atom_index); | ||
pa->name(atom.name); | ||
pa->PDBelement(atom.element.name()); | ||
pa->coords().x(atom.pos.x); | ||
pa->coords().y(atom.pos.y); | ||
pa->coords().z(atom.pos.z); | ||
pa->resid(residue.seqid.num.value); | ||
pa->chainId(chain_name); | ||
// might as well fill in segid, even though it's not official | ||
pa->segid(chain_name); | ||
pa->resname(residue.name); | ||
std::cout << atom.name << "\t" | ||
<< atom.element.name() << "\t" | ||
<< atom.pos.x << "\t" | ||
<< atom.pos.y << "\t" | ||
<< atom.pos.z << std::endl; | ||
// TODO: charge is a char*, looks like it's usually "?" in actual | ||
// mmCIF files. Perhaps a try/catch block to convert to float? | ||
|
||
// TODO: since I've got the element, in principle I can look up the | ||
// mass and atomic number, but doing so will require some changes to | ||
// AtomicNumberDeducer | ||
ag.append(pa); | ||
|
||
atom_index++; | ||
} | ||
residue_number++; | ||
} | ||
} | ||
std::cout << ag << std::endl; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
|
||
/* | ||
This file is part of LOOS. | ||
LOOS (Lightweight Object-Oriented Structure library) | ||
Copyright (c) 2023 Alan Grossfield | ||
Department of Biochemistry and Biophysics | ||
School of Medicine & Dentistry, University of Rochester | ||
This package (LOOS) is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation under version 3 of the License. | ||
This package is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
You should have received a copy of the GNU General Public License | ||
along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
#include <loos.hpp> | ||
|
||
using namespace loos; | ||
|
||
int main(int argc, char *argv[]) { | ||
|
||
std::string filename = argv[1]; | ||
MMCIF mmcif_system(filename); | ||
std::cerr << "size = " << mmcif_system.size() << std::endl; | ||
std::cerr << " centroids: " << "\t" | ||
<< mmcif_system.centroid() << std::endl; | ||
//AtomicGroup ligand = selectAtoms(mmcif_system, std::string("resname=='LIG'")); | ||
//std::cerr << "ligand size = " << ligand.size() << std::endl; | ||
//std::cerr << *(ligand[0]) << std::endl; | ||
|
||
AtomicGroup system = createSystem(filename); | ||
std::cerr << "size = " << system.size() << std::endl; | ||
std::cerr << "centroid from ag = " << system.centroid() << std::endl; | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
/* | ||
This file is part of LOOS. | ||
LOOS (Lightweight Object-Oriented Structure library) | ||
Copyright (c) 2023, Tod D. Romo, Alan Grossfield | ||
Department of Biochemistry and Biophysics | ||
School of Medicine & Dentistry, University of Rochester | ||
This package (LOOS) is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation under version 3 of the License. | ||
This package is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
You should have received a copy of the GNU General Public License | ||
along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
#include <mmcif.hpp> | ||
|
||
namespace loos { | ||
|
||
MMCIF* MMCIF::clone(void) const { | ||
return(new MMCIF(*this)); | ||
} | ||
|
||
void MMCIF::read(const std::string& filename) { | ||
auto structure = gemmi::read_structure_file(filename, gemmi::CoorFormat::Mmcif); | ||
auto unit_cell = structure.cell; | ||
auto box = loos::GCoord(unit_cell.a, unit_cell.b, unit_cell.c); | ||
|
||
periodicBox(box); | ||
|
||
// TODO: hard-wired to read first model, but there should probably be a way to read others | ||
auto model = structure.first_model(); | ||
int atom_index = 0; | ||
int residue_number = 1; | ||
for (auto chain:model.chains) { | ||
std::string chain_name = chain.name; | ||
for (auto residue:chain.residues) { | ||
std::string residue_name = residue.name; | ||
auto label_seq = residue.label_seq; | ||
std::string res_entity_id = residue.entity_id; | ||
for (auto atom:residue.atoms) { | ||
loos::pAtom pa(new loos::Atom); | ||
pa->index(atom.serial); | ||
pa->id(atom_index); | ||
pa->name(atom.name); | ||
pa->PDBelement(atom.element.name()); | ||
pa->coords().x(atom.pos.x); | ||
pa->coords().y(atom.pos.y); | ||
pa->coords().z(atom.pos.z); | ||
pa->resid(residue.seqid.num.value); | ||
pa->chainId(chain_name); | ||
// might as well fill in segid, even though it's not official | ||
pa->segid(chain_name); | ||
pa->resname(residue.name); | ||
// TODO: charge is a char*, looks like it's usually "?" in actual | ||
// mmCIF files. Perhaps a try/catch block to convert to float? | ||
|
||
pa->atomic_number(atom.element.atomic_number()); | ||
append(pa); | ||
|
||
atom_index++; | ||
} | ||
} | ||
} | ||
|
||
// assign the masses | ||
uint n_assigned = deduceMassFromAtomicNumber(); | ||
// TODO: need to add bonds | ||
} | ||
|
||
} | ||
|
||
|
Oops, something went wrong.