ex_pdb_to_fasta

ads a PDB file and writes protein sequence(s) in FASTA format

Keywords:

Categories:

  • core::data::io::Pdb

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

#include <core/data/io/Pdb.hh>
#include <core/data/structural/Structure.hh>

/** @brief Reads a PDB file and writes protein sequence(s) in FASTA format.
 *
 * This is a simplified version of ap_pdb_to_fasta_ss.cc application
 
 * USAGE:
 *     ex_pdb_to_fasta 5edw.pdb
 *
 * CATEGORIES: core::data::io::Pdb
 * KEYWORDS:   PDB input
 */
int main(const int argc, const char *argv[]) {

  using namespace core::data::io; // Pdb and create_fasta_string lives there

  Pdb reader(argv[1], is_not_alternative, true);
  core::data::structural::Structure_SP strctr = (reader.create_structure(0));

  // Iterate over all chains
  for (int ic = 0; ic < strctr->count_chains(); ++ic)
    std::cout << "> " << strctr->code() << (*strctr)[ic]->id() << "\n" // --- e.g. prints "> 2gb1 A"
      << (*strctr)[ic]->create_sequence()->sequence << "\n";           // --- prints the sequence itself
}
../_images/file_icon.png