Example Programs for counting residues

A simple start

In our first example, we will investigate a program that counts the number of times all residues accur within the PDB. In this example, we will handle threading ourselves by creating a map object which holds the residue keys using the current thread as the key.

lemon::Options o(argc, argv);

auto worker = [](const chemfiles::Frame& entry,
                 const std::string& /*unused*/) -> lemon::ResidueNameCount {

    // Desired info is calculated directly, no pruning, output is done later
    lemon::ResidueNameCount rnc;
    lemon::count::residues(entry, rnc);
    return rnc;
};

lemon::ResidueNameCount resn_total;
auto collector = lemon::map_combine<lemon::ResidueNameCount>(resn_total);
lemon::launch(o, worker, collector);

for (auto i : resn_total) {
    std::cout << i.first << "\t" << i.second << "\n";
}

Looking at a residue property

We can also count the number of bioassemblies in a entry:

auto worker = [](const chemfiles::Frame& entry,
                 const std::string& pdbid) -> std::string {

    // Desired info is obtained directly
    auto result = lemon::count::residue_property(entry, "assembly");

    // Output phase
    return pdbid + " " + std::to_string(result) + "\n";
};

auto collector = lemon::print_combine(std::cout);

or the number of alternative locations in a given entry:

auto worker = [](const chemfiles::Frame& entry,
                 const std::string& pdbid) -> std::string {

    // Desired info is obtained directly 
    auto result = lemon::count::atom_property(entry, "altloc");

    // Output phase
    return pdbid + " " + std::to_string(result) + "\n";
};

auto collector = lemon::print_combine(std::cout);