SSAGES  0.9.3
Software Suite for Advanced General Ensemble Simulations
Static Public Member Functions | List of all members
SSAGES::ReadBackbone Class Reference

Utility class to read protein backbone atoms from a reference file. More...

#include <ReadBackbone.h>

Static Public Member Functions

static std::vector< std::vector< std::string > > GetPdbBackbone (std::string refpdb, std::vector< int > resids)
 Read protein backbone atoms from reference PDB file. More...
 

Detailed Description

Utility class to read protein backbone atoms from a reference file.

This utility class allows for the backbone atoms along a protein segment to be extracted from a reference file (most likely in a .pdb).

Supported filetypes:

Definition at line 42 of file ReadBackbone.h.

Member Function Documentation

◆ GetPdbBackbone()

static std::vector< std::vector< std::string> > SSAGES::ReadBackbone::GetPdbBackbone ( std::string  refpdb,
std::vector< int >  resids 
)
inlinestatic

Read protein backbone atoms from reference PDB file.

Parameters
refpdbName of reference PDB file.
residsVector of residue numbers for which to find backbone atoms.
Returns
atomids Vector of atom numbers corresponding to specified residues.

Extract backbone atom from a reference PDB file, corresponding to a sequence of protein residues of interest. Five backbone atoms are extracted for each residue in the order: N CA CB C O. For Glycine residues, HA1 is located in place of CB.

Definition at line 57 of file ReadBackbone.h.

58  {
59  //std::vector<int> atomids;
60  std::vector< std::vector< std::string > > atomids(2, std::vector<std::string> (0));
61  //std::vector<int> atomnums;
62  std::vector<std::string> atomnums;
63  std::vector<std::string> atomtypes;
64  std::vector<std::string> resnames;
65  std::vector<std::string> chains;
66  std::vector<int> resnums;
67  //std::vector<int> tempatoms(5);
68  std::vector<std::string> tempatoms(5);
69  std::vector<std::string> backboneAtoms = {"N", "CA", "CB", "C", "O", "OT1"};
70  std::vector<std::string> glycineAtoms = {"N", "CA", "HA1", "C", "O", "OT1"};
71  std::string atomnum, resnum;
72  std::string record, atomtype, resname, chain;
73  std::ifstream pdbfile;
74  pdbfile.open(refpdb, std::ios::in);
75  std::string line;
76 
77  while(std::getline(pdbfile, line)){
78  if(line.length() < 26) line.append(26 - line.length(), ' ');
79  record = line.substr(0, 6);
80  atomnum = line.substr(6, 5);
81  atomtype = line.substr(12, 4);
82  resname = line.substr(17, 3);
83  chain = line.substr(21, 1);
84  resnum = line.substr(22, 4);
85  record.erase( std::remove( record.begin(), record.end(), ' '), record.end());
86  if((record == "ATOM") && ((std::stoi(resnum) - resids[0]) <= (resids.back() - resids[0]))){
87  atomtype.erase( std::remove( atomtype.begin(), atomtype.end(), ' '), atomtype.end());
88  resname.erase( std::remove( resname.begin(), resname.end(), ' '), resname.end());
89  if(resname == "GLY" && std::find(glycineAtoms.begin(), glycineAtoms.end(), atomtype) != glycineAtoms.end()){
90  //atomnums.push_back(std::stoi(atomnum));
91  atomnums.push_back(atomnum);
92  atomtypes.push_back(atomtype);
93  resnames.push_back(resname);
94  chains.push_back(chain);
95  resnums.push_back(std::stoi(resnum));
96  } else if(std::find(backboneAtoms.begin(), backboneAtoms.end(), atomtype) != backboneAtoms.end()){
97  //atomnums.push_back(std::stoi(atomnum));
98  atomnums.push_back(atomnum);
99  atomtypes.push_back(atomtype);
100  resnames.push_back(resname);
101  chains.push_back(chain);
102  resnums.push_back(std::stoi(resnum));
103  }
104  }
105  }
106 
107  // atoms in PDB not necessarily in N CA CB C O order, fix that:
108  for(size_t i = 0; i < resids.size(); i++){
109  for(size_t j = 5 * i; j < (5 * i + 5); j++){
110  if(atomtypes[j] == "N"){
111  tempatoms[0] = atomnums[j];
112  std::cout << "N - Atom " << tempatoms[0] << " - Chain " << chains[j] << std::endl;
113  } else if(atomtypes[j] == "CA"){
114  tempatoms[1] = atomnums[j];
115  std::cout << "CA - Atom " << tempatoms[1] << " - Chain " << chains[j] << std::endl;
116  } else if(atomtypes[j] == "C"){
117  tempatoms[3] = atomnums[j];
118  std::cout << "C - Atom " << tempatoms[3] << " - Chain " << chains[j] << std::endl;
119  } else if(atomtypes[j] == "O"){
120  tempatoms[4] = atomnums[j];
121  std::cout << "O - Atom " << tempatoms[4] << " - Chain " << chains[j] << std::endl;
122  } else if(atomtypes[j] == "OT1"){
123  tempatoms[4] = atomnums[j];
124  std::cout << "OT1- Atom " << tempatoms[4] << " - Chain " << chains[j] << std::endl;
125  } else{
126  tempatoms[2] = atomnums[j];
127  std::cout << atomtypes[j] << " - Atom " << tempatoms[2] << " - Chain " << chains[j] << std::endl;
128  }
129  atomids[1].push_back(chains[j]);
130  }
131  //atomids.insert(atomids.end(), tempatoms.begin(), tempatoms.end());
132  atomids[0].insert(atomids[0].end(), tempatoms.begin(), tempatoms.end());
133  }
134 
135  return atomids;
136  }

Referenced by SSAGES::AlphaRMSDCV::Initialize(), SSAGES::AntiBetaRMSDCV::Initialize(), and SSAGES::ParallelBetaRMSDCV::Initialize().

Here is the caller graph for this function:

The documentation for this class was generated from the following file: