File: peptideBuilder.C

package info (click to toggle)
ball 1.5.0%2Bgit20180813.37fc53c-6
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 239,888 kB
  • sloc: cpp: 326,149; ansic: 4,208; python: 2,303; yacc: 1,778; lex: 1,099; xml: 958; sh: 322; makefile: 95
file content (640 lines) | stat: -rw-r--r-- 18,268 bytes parent folder | download | duplicates (4)
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
/// -*- Mode: C++; tab-width: 2; -*-
// vi: set ts=2:
//

#include <BALL/STRUCTURE/peptideBuilder.h>

#include <BALL/MATHS/analyticalGeometry.h>
#include <BALL/STRUCTURE/geometricTransformations.h>
#include <BALL/KERNEL/PTE.h>
#include <cmath>
#include <BALL/STRUCTURE/fragmentDB.h>

namespace BALL
{
	namespace Peptides
	{

		// Default bond lengths for divers bonds in the peptide backbone.
		const float BOND_LENGTH_N_C  = 1.335;
		const float BOND_LENGTH_C_CA = 1.520;
		const float BOND_LENGTH_N_CA = 1.450;
		const float BOND_LENGTH_C_O  = 1.240;
		const float BOND_LENGTH_N_H  = 1.020;

		AminoAcidDescriptor::AminoAcidDescriptor()
			:type_(),
			 phi_(Angle(-47.,false)),
			 psi_(Angle(-58.,false)),
			 omega_(Angle(Constants::PI,true))
		{
		}

		AminoAcidDescriptor::AminoAcidDescriptor
			(const String& type, const Angle& phi,
			 const Angle& psi, const Angle& omega)
			: phi_(phi),
				psi_(psi),
				omega_(omega)
		{
			if (type.size() == 1)
			{
				type_ = ThreeLetterCode(type.toChar());
			}
			else
			{
				type_ = type;
			}
		}


		// inline functions (alle accessors), dtors ????
		AminoAcidDescriptor::~AminoAcidDescriptor()
		{
		}


		AminoAcidDescriptor::AminoAcidDescriptor(const AminoAcidDescriptor& aad)
			: type_(aad.getType()),
				phi_(aad.getPhi()),
				psi_(aad.getPsi()),
				omega_(aad.getOmega())
		{
		}


		void AminoAcidDescriptor::setAminoAcidType(const String& type)
		{
			if (type.size() == 1)
			{
				type_ = ThreeLetterCode(type.toChar());
			}
			else
			{
				type_ = type;
			}
		}

		void AminoAcidDescriptor::setPhi(const Angle& phi)
		{
			phi_ = phi;
		}

		void AminoAcidDescriptor::setPsi(const Angle& psi)
		{
			psi_ = psi;
		}

		void AminoAcidDescriptor::setOmega(const Angle& omega)
		{
			omega_ = omega;
		}

		const String& AminoAcidDescriptor::getType() const
		{
			return type_;
		}

		const Angle& AminoAcidDescriptor::getPhi() const
		{
			return phi_;
		}

		const Angle& AminoAcidDescriptor::getPsi() const
		{
			return psi_;
		}

		const Angle& AminoAcidDescriptor::getOmega() const
		{
			return omega_;
		}

		PeptideBuilder::PeptideBuilder()
			: sequence_(),
				chainname_("Chain"),
				proteinname_("Protein"),
				is_proline_(false),
				fragment_db_(0)
		{
		}

		PeptideBuilder::PeptideBuilder(const std::vector<AminoAcidDescriptor>& sequence)
			: sequence_(sequence),
				chainname_("Chain"),
				proteinname_("Protein"),
				is_proline_(false),
				fragment_db_(0)
		{
		}

		PeptideBuilder::PeptideBuilder(const String& sequence, const Angle& phi, const Angle& psi, const Angle& omega)
			: sequence_(),
				chainname_("_"),
				proteinname_(sequence),
				is_proline_(false),
				fragment_db_(0)
		{
			// Iterate over the sequence (one-letter code) and construct
			// add descriptors for the aa with the given geometry.
			for (Position i = 0; i < sequence.length(); ++i)
			{
				addAminoAcid(sequence[i], phi, psi, omega);
			}
		}

		PeptideBuilder::PeptideBuilder(const PeptideBuilder& pc)
			:sequence_(pc.sequence_),
			 chainname_(pc.chainname_),
			 proteinname_(pc.proteinname_),
			 is_proline_(false),
			 fragment_db_(0)
		{
		}

		PeptideBuilder::~PeptideBuilder()
		{
		}


		void PeptideBuilder::addAminoAcid
			(const String& type, const Angle& phi, const Angle& psi, const Angle& omega)
		{
			AminoAcidDescriptor aa(type, phi, psi, omega);
			sequence_.push_back(aa);
		}

		void PeptideBuilder::addAminoAcid(const AminoAcidDescriptor& aad)
		{
			sequence_.push_back(aad);
		}

		void PeptideBuilder::setChainName(const String& name)
		{
			chainname_ = name;
		}

		const String& PeptideBuilder::getChainName() const
		{
			return chainname_;
		}

		void PeptideBuilder::setProteinName(const String& name)
		{
			proteinname_ = name;
		}

		const String& PeptideBuilder::getProteinName() const
		{
			return proteinname_;
		}

		Protein* PeptideBuilder::construct()
		{
			if (fragment_db_ == 0)
			{
				Log.warn() << "PeptideBuilder::construct(): no FragmengDB given!" << std::endl;
				return 0;
			}
			if (sequence_.empty())
			{

				Log.warn() << "PeptideBuilder::construct(): no amino acid sequence specified." << std::endl;
				return 0;
			}
			int id = 1;
			Protein *protein = new Protein(proteinname_);
			Chain *chain = new Chain(chainname_);

			// create the first residue
			Residue* residue = createResidue_(sequence_[0].getType(), id);
			chain->insert(*residue);
			Residue* residueold = residue;
			std::vector<AminoAcidDescriptor>::iterator i = sequence_.begin();
			++id;

			// consistency check for empty sequences and sequences of length < 2!!	
			// loop for the remaining residues ;
			for (++i; i != sequence_.end(); ++i)
			{
				// We have to take care of two special cases:
				// 		- the residue we are looking at is proline
				// 		- the last residue was proline
				String type = (i-1)->getType();
				type.toUpper();

				// special case: residue is a proline
				type = i->getType();
				type.toUpper();
				is_proline_ = type == "PRO";

				Residue* residue2 = createResidue_(i->getType(), id);

				insert_(*residue2, *residueold);
				chain->insert(*residue2);

				// set the torsion angle 
				transform_(i->getPhi(), (i-1)->getPsi(),*residueold, *residue2);
				peptide_(*residueold,*residue2);

				// set the peptide bond angle omega
				setOmega_(*residueold, *residue2, i->getOmega());

				residueold=residue2;
				++id;
			}

			protein->insert(*chain);

			// read the names for a unique nomenclature 
			protein->apply(fragment_db_->normalize_names);

			// add missing bonds and atoms (including side chains!)
			ReconstructFragmentProcessor rfp(*fragment_db_);
			protein->apply(rfp);
			protein->apply(fragment_db_->build_bonds);

			return protein;
		}

		Residue* PeptideBuilder::createResidue_(const String& type, const int id)
		{
			Residue* res = new Residue(type, String(id));
			PDBAtom* nitrogen = new PDBAtom(PTE[Element::N], "N");
			PDBAtom* carbona = new PDBAtom(PTE[Element::C], "CA");
			PDBAtom* carbon = new PDBAtom(PTE[Element::C], "C");

			// put CA into the starting position 
			carbona->setPosition(Vector3( 0.00, 0.00, 0.0));

			// insert N and C 
			nitrogen->setPosition(Vector3(-1 * BOND_LENGTH_N_CA, 0.00,  0.00));
			carbon->setPosition
				(Vector3(BOND_LENGTH_C_CA * (cos(Constants::PI * 71./180.)),
								 0.00,
								 BOND_LENGTH_C_CA * (sin(Constants::PI * 71. / 180.))));

			// insert atomes into residue/chain/protein
			res->insert(*nitrogen);
			res->insert(*carbona);
			res->insert(*carbon);

			// flag as an amino acid  
			res->setProperty(Residue::PROPERTY__AMINO_ACID);

			// create the bonds
			nitrogen->createBond(*carbona)->setOrder(Bond::ORDER__SINGLE);
			carbona->createBond(*carbon)->setOrder(Bond::ORDER__SINGLE);

			return res;
		}

		void PeptideBuilder::insert_(Residue& resnew, Residue& resold)
		{
			PDBAtom* pcarbon     = getAtomByName_(resold, "C");
			PDBAtom* pcarbona    = getAtomByName_(resold, "CA");
			PDBAtom* pnitrogen   = getAtomByName_(resold, "N");
			PDBAtom* pnitrogen_n = getAtomByName_(resnew, "N");
			PDBAtom* pcarbona_n  = getAtomByName_(resnew, "CA");
			PDBAtom* pcarbon_n   = getAtomByName_(resnew, "C");

			Vector3 rot_axis;    // axis  for the torsion angle

			// set C-N-bond 
			pcarbon->createBond(*pnitrogen_n)->setOrder(Bond::ORDER__SINGLE);;


			//  --------------  move N into  0|0|0   
			TranslationProcessor translation(Vector3(BOND_LENGTH_N_CA, 0., 0.));
			resnew.apply(translation);

			// --------------- calculate the coordinates for N
			Vector3 CA_C_axis = (pcarbon->getPosition() - pcarbona->getPosition()).normalize();
			Vector3 N_CA_axis = (pcarbona->getPosition() - pnitrogen->getPosition()).normalize();
			Vector3 CA_N_axis = ((float)-1.) * N_CA_axis;
			Vector3 newpos = (CA_N_axis - (CA_C_axis * CA_N_axis) * CA_C_axis).normalize();
			Vector3 normaxis = (CA_C_axis % newpos).normalize();

			Matrix4x4 mat;
			mat.setRotation(Angle(-1. * 30.* Constants::PI/180.), normaxis);

			newpos = mat * newpos;               // rotation
			newpos = newpos *  BOND_LENGTH_N_C;  // scaling of the bond length
			newpos = newpos + pcarbon->getPosition();

			// positioning of the nitrogen
			translation.setTranslation(newpos);
			resnew.apply(translation);


			 //---------------set the angle in NN to 120 degrees
			Vector3 NN_C_axis   = pcarbon->getPosition() - pnitrogen_n->getPosition();
			Vector3 NN_NCA_axis = pcarbona_n->getPosition() - pnitrogen_n->getPosition();
			CA_C_axis = pcarbon->getPosition() - pcarbona->getPosition();

			// current angle for C
			Angle current(acos(NN_C_axis * NN_NCA_axis /
										 (NN_C_axis.getLength() * NN_NCA_axis.getLength() )));

			Matrix4x4 transmat;
			Vector3 rotaxis;

			if (current < (float)(Constants::PI - 1e-2))
			{
				current = Angle(120.*Constants::PI/180.) - current;
				rotaxis = (NN_C_axis%NN_NCA_axis).normalize();
			}
			else
			{
				if (current > (float)(Constants::PI+1e-2))
				{
				  // is this line really correct???
					current = Angle(-120. * 120. * Constants::PI / 180.) - current;
					rotaxis = (NN_C_axis % NN_NCA_axis).normalize();
				}
				else
				{
					current = Angle(-120. * Constants::PI / 180.) - current;
					rotaxis = (NN_C_axis%CA_C_axis).normalize();
				}
			}

			transmat.rotate(current, rotaxis);

			TransformationProcessor transformation(transmat);

			// translate to 0|0|0 (needed for the rotation)
			Vector3 toOrigin = pnitrogen_n->getPosition();
			translation.setTranslation(((float)(-1.))*toOrigin);
			resnew.apply(translation);
			// rotate in 0|0|0
			resnew.apply(transformation);
			// translate back to the correct position
			translation.setTranslation(toOrigin);
			resnew.apply(translation);

			//---------------- set torsion angle to 0
			Vector3 v_pca  = pcarbona->getPosition();
			Vector3 v_pc   = pcarbon->getPosition();
			Vector3 v_pn_n = pnitrogen_n->getPosition();
			Vector3 v_pca_n = pcarbona_n->getPosition();
			Vector3 v_pc_n  = pcarbon_n->getPosition();
			Vector3 v_pn   =pnitrogen->getPosition();
			current = getTorsionAngle( v_pca.x,   v_pca.y,   v_pca.z,
					 v_pc.x,    v_pc.y,    v_pc.z,
					 v_pn_n.x,  v_pn_n.y,  v_pn_n.z,
					 v_pca_n.x, v_pca_n.y, v_pca_n.z );


			rot_axis =  (pnitrogen_n->getPosition() - pcarbon->getPosition()).normalize();
			transmat.getZero();/// is this necessary???
			transmat.rotate(Angle(-1. * current), rot_axis);
			transformation.setTransformation(transmat);

			// translate to 0|0|0
			toOrigin = pnitrogen_n->getPosition();
			translation.setTranslation(((float)(-1.))*toOrigin);
					resnew.apply(translation);
			// set torsion angles
			 resnew.apply(transformation);

			// translate back
			translation.setTranslation(toOrigin);
			resnew.apply(translation);

			// ---------------------set the peptide bond angle omega  to 180 degrees
			v_pca  = pcarbona->getPosition();
			v_pc   = pcarbon->getPosition();
			v_pn_n = pnitrogen_n->getPosition();
			v_pca_n = pcarbona_n->getPosition();
			v_pc_n  = pcarbon_n->getPosition();
			current = getTorsionAngle( v_pca.x,   v_pca.y,   v_pca.z,
					 v_pc.x,    v_pc.y,    v_pc.z,
					 v_pn_n.x,  v_pn_n.y,  v_pn_n.z,
					 v_pca_n.x, v_pca_n.y, v_pca_n.z );

			transmat.getZero();
			transmat.rotate( Angle(Constants::PI , true),
					 (pnitrogen_n->getPosition() - pcarbon->getPosition()).normalize());
			transformation.setTransformation(transmat);
			// translate to 0|0|0 (needed for the rotation)
			toOrigin = pnitrogen_n->getPosition();
			translation.setTranslation(((float)(-1.))*toOrigin);
			resnew.apply(translation);
			//rotate in 0|0|0  about 180 degrees
			resnew.apply(transformation);
			//translate back
			translation.setTranslation(toOrigin);
			 resnew.apply(translation);

			//------------- angle psi
			v_pca  = pcarbona->getPosition();
			v_pc   = pcarbon->getPosition();
			v_pn_n = pnitrogen_n->getPosition();
			v_pca_n = pcarbona_n->getPosition();
			v_pc_n  = pcarbon_n->getPosition();
			current = getTorsionAngle( v_pc.x,    v_pc.y,    v_pc.z,
					 v_pn_n.x,  v_pn_n.y,  v_pn_n.z,
					 v_pca_n.x, v_pca_n.y, v_pca_n.z,
					 v_pc_n.x,  v_pc_n.y,  v_pc_n.z  );

			rot_axis = (pcarbona_n->getPosition()-pnitrogen_n->getPosition()).normalize();

			transmat.rotate(Angle(-1. * current), rot_axis);
			transformation.setTransformation(transmat);

			//translate to 0|0|0 (needed for the rotation)
			toOrigin = pcarbona_n->getPosition();
			translation.setTranslation(((float)(-1.))*toOrigin);
			 resnew.apply(translation);

			resnew.apply(transformation);
			// translate back to the correct position
			translation.setTranslation(toOrigin);
			resnew.apply(translation);

			return;
		}

		void PeptideBuilder::transform_
			(const Angle& phi, const Angle& psi, Residue& resold, Residue& resnew)
		{
			Matrix4x4 psimat;   // rotation matrix
			Matrix4x4 phimat;   //    "
			Vector3   psiaxis;  // rotation axis for the torsion angles
			Vector3   phiaxis;
			TranslationProcessor translation;


			PDBAtom* pcarbon     = getAtomByName_(resold, "C");
			PDBAtom* pcarbona    = getAtomByName_(resold, "CA");
			PDBAtom* pnitrogen_n = getAtomByName_(resnew, "N");
			PDBAtom* pcarbona_n  = getAtomByName_(resnew, "CA");
			PDBAtom* pcarbon_n   = getAtomByName_(resnew, "C");
			PDBAtom* pnitrogen   = getAtomByName_(resold, "N");
			Angle currentpsi;
			Angle currentphi;

			Vector3 v_pn     = pnitrogen->getPosition();
			Vector3 v_pca    = pcarbona->getPosition();
			Vector3 v_pc     = pcarbon->getPosition();
			Vector3 v_pn_n   = pnitrogen_n->getPosition();
			Vector3 v_pca_n  = pcarbona_n->getPosition();
			Vector3 v_pc_n   = pcarbon_n->getPosition();
			currentpsi = getTorsionAngle( v_pn.x,    v_pn.y,   v_pn.z,
							v_pca.x,   v_pca.y,  v_pca.z,
							v_pc.x,  v_pc.y, v_pc.z,
							v_pn_n.x,  v_pn_n.y,  v_pn_n.z);

			psiaxis = ( pcarbon->getPosition() - pcarbona->getPosition()).normalize();
			psimat.rotate((float)-1. * currentpsi, psiaxis);
			TransformationProcessor psitrans(psimat);

			//translate  to 0|0|0 (needed for the rotation)
			Vector3 toOrigin = pcarbon->getPosition();
			translation.setTranslation(((float)(-1.))*toOrigin);
			resnew.apply(translation);

			//rotate
			resnew.apply(psitrans);

			psimat.rotate(psi, psiaxis);
			psitrans.setTransformation(psimat);
			resnew.apply(psitrans);

			//translate back
			translation.setTranslation(toOrigin);
			resnew.apply(translation);

			v_pn     = pnitrogen->getPosition();
			v_pca    = pcarbona->getPosition();
			v_pc     = pcarbon->getPosition();
			v_pn_n   = pnitrogen_n->getPosition();
			v_pca_n  = pcarbona_n->getPosition();
			v_pc_n   = pcarbon_n->getPosition();

			currentphi = getTorsionAngle( v_pc.x,    v_pc.y,    v_pc.z,
					 v_pn_n.x,  v_pn_n.y,  v_pn_n.z,
					 v_pca_n.x, v_pca_n.y, v_pca_n.z,
					 v_pc_n.x,  v_pc_n.y,  v_pc_n.z);


			phiaxis = (pcarbona_n->getPosition() -  pnitrogen_n->getPosition()).normalize();
			phimat.rotate(phi, phiaxis);
			TransformationProcessor phitrans(phimat);

			// translate to 0|0|0 (needed for the rotation)
			toOrigin =  pcarbona_n->getPosition();
			translation.setTranslation(((float)(-1.))*toOrigin);
			resnew.apply(translation);

			// rotate 
			resnew.apply(phitrans);

			// translate back to the correct position
			translation.setTranslation(toOrigin);
			resnew.apply(translation);

			return;
		}

		void PeptideBuilder::peptide_(Residue& resold, Residue& resnew)
		{
			PDBAtom* poxygen = new PDBAtom(PTE[Element::O], "O");
			// dynamic_cast<PDBAtom*>(resold->getAtom("C"));   ?????
			PDBAtom* pcarbon     = getAtomByName_(resold, "C");
			PDBAtom* pcarbona    = getAtomByName_(resold, "CA");
			PDBAtom* pnitrogen_n = getAtomByName_(resnew, "N");

			Vector3 CA_C_axis =(pcarbon->getPosition() - pcarbona->getPosition()).normalize();
			Vector3 C_NN_axis =(pnitrogen_n->getPosition() - pcarbon->getPosition()).normalize();

			Matrix4x4 mat;
			mat.setRotation(Angle(Constants::PI), CA_C_axis);
			Vector3  newpos = mat * C_NN_axis;

			// newpos = mat * newpos; 
			newpos = newpos.normalize() * BOND_LENGTH_C_O + pcarbon->getPosition();

			//newpos= pcarbon->getPosition();
			poxygen->setPosition(newpos);

			//set C-O-bond
			(pcarbon->createBond(*poxygen))->setOrder(Bond::ORDER__DOUBLE);
			resold.insert(*poxygen);

			//----------set hydrogen. We can't do this for proline,
			//					since in this case, this hydrogen doesn't exist
			if (!is_proline_)
			{
				PDBAtom* phydrogen = new PDBAtom(PTE[Element::H], "H");
				pcarbon     = getAtomByName_(resold, "C");
				pnitrogen_n = getAtomByName_(resnew, "N");
				poxygen     = getAtomByName_(resold, "O");

				newpos =  (pcarbon->getPosition() - poxygen->getPosition()).normalize();

				newpos = newpos * BOND_LENGTH_N_H + pnitrogen_n->getPosition();
				phydrogen->setPosition(newpos);
				phydrogen->createBond(*pnitrogen_n)->setOrder(Bond::ORDER__SINGLE);;
				resnew.insert(*phydrogen);
			}
			return;
		}

		void PeptideBuilder::setOmega_(Residue& resold, Residue& resnew, const Angle& omega)
		{
			PDBAtom* pcarbon     = getAtomByName_(resold, "C");
			PDBAtom* pnitrogen_n = getAtomByName_(resnew, "N");

			Vector3 C_NN_axis =(pnitrogen_n->getPosition() - pcarbon->getPosition()).normalize();

			// At this point, omega has been fixed to 180 degrees
			Matrix4x4 mat;
			mat.setRotation(Angle(omega-Angle(Constants::PI)), C_NN_axis);
			TransformationProcessor omegatrans(mat);

			// translate to 0|0|0 (needed for the rotation)
			Vector3 toOrigin =  pnitrogen_n->getPosition();
			TranslationProcessor translation;
			translation.setTranslation(((float)(-1.))*toOrigin);
			resnew.apply(translation);

			// rotate 
			resnew.apply(omegatrans);

			// translate back to the correct position
			translation.setTranslation(toOrigin);
			resnew.apply(translation);

			return;
		}

		PDBAtom* PeptideBuilder::getAtomByName_(Residue& res, const String& name)
		{
			PDBAtomIterator ai;
			for (ai = res.beginPDBAtom(); +ai; ++ai)
			{
				if (ai->getName() == name)
				{
					return &(*ai);
				}
			}

			return 0;
		}


		void PeptideBuilder::setFragmentDB(const FragmentDB* db)
		{
			fragment_db_ = (FragmentDB*) db;
		}

		const FragmentDB* PeptideBuilder::getFragmentDB() const
		{
			return fragment_db_;
		}


	} // namespace Peptides
} // namespace BALL