Some users may wish to write Lemon workflows that involve the alignment of a potential protein to a reference protein. Potential applications include the creation of a benchmarking set of all proteins with a given fold or motif. To address this, we’ve included the TMalign algorithm within Lemon.

Note: You will need to include the additional file: <lemon/tmalign.hpp> to have access to these features.

The TMscore function for alignment

struct TMResult

Structure representing the TMScore

TMResult tmalign::lemon::TMscore(const chemfiles::Frame &search, const chemfiles::Frame &native)

TMalign is an algorithm used to align protein chains in 3D space.

Ported from Original reference: Yang Zhang, Jeffrey Skolnick, Proteins 2004 57:702-10.

Original License: Permission to use, copy, modify, and distribute this program for any purpose, with or without fee, is hereby granted, provided that the notices on the head, the reference information, and this copyright notice appear in all copies or substantial portions of the Software. It is provided “as is” without express or implied warranty.


A strucure with the TMScore, and number of aligned residues

  • [in] search: The frame that is being aligned to native.

  • [in] native: The ‘native’ chain that the search chain is aligned to.



lemon::Options o;
auto reference = std::string("reference.pdb");
o.add_option("--reference,-r", reference, "Protein or DNA to align to.")->
o.parse_command_line(argc, argv);

chemfiles::Trajectory traj(reference);
chemfiles::Frame native =;

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

    auto tm = lemon::tmalign::TMscore(entry, native);

    return pdbid + "\t" +
           std::to_string(tm.score) + "\t" +
           std::to_string(tm.rmsd) + "\t" +
           std::to_string(tm.aligned) + "\n";

auto collector = lemon::print_combine(std::cout);
return lemon::launch(o, worker, collector);


import lemon

class MyWorkflow(lemon.Workflow):
    def __init__(self):
        import lemon
        self.native = lemon.open_file("../../../test/files/1AAQ.mmtf")
    def worker(self, entry, pdbid):
        import lemon

        tm = lemon.TMscore(entry, self.native)

        return pdbid + "\t" + \
               str(tm.score) + "\t" + \
               str(tm.aligned) + "\t" + \
               str(tm.affine) + "\n"