ex_Sequence

ex_Sequence reads a PDB file and prints a sequence fragment. It demonstrates how to select residues by their PDB_ID

USAGE:
./ex_Sequence 3wn7.pdb

Categories:

  • core/data/io/Sequence

Input files:

Output files:

Program source:

 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
40
#include <iostream>

#include <core/data/io/Pdb.hh>
#include <core/data/io/fasta_io.hh>
#include <utils/exit.hh>

std::string program_info = R"(

ex_Sequence reads a PDB file and prints a sequence fragment. It demonstrates
how to select residues by their PDB_ID
USAGE:
    ./ex_Sequence 3wn7.pdb

)";

/** @brief Reads a PDB file and prints a fragment of its sequence.
 *
 * CATEGORIES: core/data/io/Sequence
 * KEYWORDS:   PDB input; Structure; sequence; structure selectors
 */
int main(const int argc, const char* argv[]) {

  if(argc < 2) utils::exit_OK_with_message(program_info); // --- complain about missing program parameter
    
  using namespace core::data::io;

  // --- Try this test program with 3wn7 as the input structure !
  Pdb reader(argv[1], // file name (PDB format, may be gzip-ped)
    all_true(is_not_hydrogen,is_not_water),          // don't read hydrogens, skip water molecules
    true);          //  parse PDB header !

  auto structure = reader.create_structure(0);
  auto chain = structure->get_chain('A');
  auto sequence = chain->create_sequence();

  // --- Should be 324 (324 is the ID of the very first residue of 3wn7 chain A)
  std::cout << "Id of the first residue: " << sequence->first_pos()<<"\n";
  Sequence fragment(*sequence,366,405); // Cut from residue whose ID is 366
  std::cout << fragment.first_pos() << " " << fragment.sequence << "\n";
}
../_images/file_icon.png