File size: 875 Bytes
2e3030d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include <filesystem>
#include <iostream>

#include <cif++.hpp>

namespace fs = std::filesystem;

int main(int argc, char *argv[])
{
	if (argc != 2)
	{
		std::cerr << "Usage: example <inputfile>\n";
		exit(1);
	}

	cif::file file = cif::pdb::read(argv[1]);

	if (file.empty())
	{
		std::cerr << "Empty file\n";
		exit(1);
	}

	auto &db = file.front();
	auto &atom_site = db["atom_site"];
	auto n = atom_site.find(cif::key("label_atom_id") == "OXT").size();

	std::cout << "File contains " << atom_site.size() << " atoms of which " << n << (n == 1 ? " is" : " are") << " OXT\n"
			  << "residues with an OXT are:\n";

	for (const auto &[asym, comp, seqnr] : atom_site.find<std::string, std::string, int>(
			 cif::key("label_atom_id") == "OXT", "label_asym_id", "label_comp_id", "label_seq_id"))
	{
		std::cout << asym << ' ' << comp << ' ' << seqnr << '\n';
	}

	return 0;
}