Counting operations

These operations are provided so that the user can easily count the number of times a given property occurs. All operations are availible in C++ and Python. Python functions are prefixed with count_ instead of using the namespace resolution.

Provided selectors

namespace lemon::count

Count various biological features.

Functions

ResidueNameCount &residues(const chemfiles::Frame &frame, ResidueNameCount &resn_count)

Append all residue counts in a Frame to a ResidueNameCount

Use this function to count the all residues in frame using the residue name. If the residue is previously stored in the supplied resn_count then the count of the residue is increased.

Parameters
  • [in] frame: The frame containing residues of interest

  • [inout] resn_count: A map of residue names to their respective count

template<typename Container>
ResidueNameCount &residues(const chemfiles::Frame &frame, const Container &resids, ResidueNameCount &resn_count)

Append selected residue counts in a Frame to a ResidueNameCount

Use this function to count the residues in frame using the residue name with the residue ids in resids. If the residue is previously stored in the supplied resn_count then the count of the residue is increased.

Parameters
  • [in] frame: The frame containing residues of interest

  • [in] resids: Residue ids to consider

  • [inout] resn_count: A map of residue names to their respective count

size_t atom_property(const chemfiles::Frame &frame, const std::string &name)

Obtain the number of times a given property occurs in a Frame.

Return

the number of unique alternative location names

Parameters
  • [in] frame: The frame containing atoms of interest.

  • [in] name: The name of the property

size_t residue_property(const chemfiles::Frame &frame, const std::string &name)

Obtain the number of bioassemblies in a Frame.

Return

the number of unique bioassemblies location names

Parameters
  • [in] frame: The frame containing residues of interest.

  • [in] name: The name of the property

template<typename Container>
std::string print_residue_names(const chemfiles::Frame &entry, const Container &res_ids)

Print select residue names and their respective counts

Return

a string containing the formatted output.

Parameters
  • [in] entry: The entry containing the residues of interest

  • [in] res_ids: The set of residue ids for printing

Examples

C++

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";
}

Python

from __future__ import print_function
import lemon

class MyWorkflow(lemon.Workflow):
    def __init__(self):
        import lemon
        lemon.Workflow.__init__(self)
        self.rnc = {}
    def worker(self, entry, pdbid):
        import lemon
        self.rnc = lemon.count_residues(entry, self.rnc)
        return ""