Skip to content

Commit

Permalink
first version
Browse files Browse the repository at this point in the history
  • Loading branch information
giopina committed Jul 4, 2016
0 parents commit 7bc94eb
Show file tree
Hide file tree
Showing 44 changed files with 12,104 additions and 0 deletions.
220 changes: 220 additions & 0 deletions Bead.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,220 @@
/*
* Bead.h
*
* Created on: Jul 19, 2012
* Author: gpolles
*
* Bead class.
* Each bead has 3 coordinates and pointers to its neighbors
* and to a domain.
* It have also some information from the pdb file
* as chainId, and betaFactor
*
*/

#ifndef BEAD_H_
#define BEAD_H_

#include <vector>

#include "Vector3d.h"
#include "common.h"


class RigidDomain;

class Bead
{
public:
Bead() : _index(0), _num_neighbors(0),_num_covBonded(0), _domain(NULL),
_isEdge(false), _coordinates(Vector3d(0,0,0)),
_atomType(""),_resNum(0),_resName(""),_hetatm(false),
_betaFactor(0.0), _pdbPosition(0), _chainId(0) {}
virtual ~Bead(){}

double distance(Bead* b){
return _coordinates.distance(b->_coordinates);
}

double distance(Bead& b){
return _coordinates.distance(b._coordinates);
}

double distanceSQ(Bead* b){
return _coordinates.distanceSQ(b->_coordinates);
}

double distanceSQ(Bead& b){
return _coordinates.distanceSQ(b._coordinates);
}

RigidDomain* getDomain() const {
return _domain;
}

void setDomain(RigidDomain* domain){
_domain = domain;
}

int getIndex() const {
return _index;
}

bool getHet() {
return _hetatm;
}

void setHet(bool HET) {
_hetatm=HET;
}

void setIndex(int index) {
_index = index;
}

std::vector<Bead*>& getNeighbors() {
return _neighbors;
}

void setNeighbors(std::vector<Bead*> neighbors) {
_neighbors = neighbors;
}

int getNumNeighbors() const {
return _num_neighbors;
}

void setNumNeighbors(int numNeighbors) {
_num_neighbors = numNeighbors;
}

void addNeighbor(Bead* neighbor){
_neighbors.push_back(neighbor);
_num_neighbors = _neighbors.size();
}



/************************/
std::vector<Bead*>& getCovBonded() {
return _covBonded;
}

void setCovBonded(std::vector<Bead*> covBonded) {
_covBonded = covBonded;
}

int getNumCovBonded() const {
return _num_covBonded;
}

void setNumCovBonded(int numCovBonded) {
_num_covBonded = numCovBonded;
}

void addCovBond(Bead* covbond){
_covBonded.push_back(covbond);
_num_covBonded = _covBonded.size();
}

/***********************/


bool isEdge(){
return _isEdge;
}

void setEdge(bool b){
_isEdge =b;
}

double getBetaFactor() const {
return _betaFactor;
}

void setBetaFactor(double betaFactor) {
_betaFactor = betaFactor;
}

//#####################################
std::string getAtomType() {
return _atomType;
}
void setAtomType(std::string type) {
_atomType=type;
}

int getBeadType() {
return _beadType;
}
void setBeadType(int type) {
_beadType=type;
}

std::string getResName() {
return _resName;
}
void setResName(std::string name) {
_resName=name;
}

int getResNum() {
return _resNum;
}
void setResNum(int resnum) {
_resNum=resnum;
}
//####################################




const Vector3d& getCoordinates() const {
return _coordinates;
}

void setCoordinates(const Vector3d& coordinates) {
_coordinates = coordinates;
}

int getPdbPosition() const {
return _pdbPosition;
}

void setPdbPosition(int pdbPosition) {
_pdbPosition = pdbPosition;
}

int getChainId() const {
return _chainId;
}

void setChainId(int chainId) {
_chainId = chainId;
}

private:
int _index;
int _num_neighbors;
int _num_covBonded;
RigidDomain* _domain;
std::vector<Bead*> _neighbors;
std::vector<Bead*> _covBonded;
bool _isEdge;
Vector3d _coordinates;
double _betaFactor;
int _pdbPosition;
bool _hetatm;


int _beadType; // 0 -> P
// 1 -> sugar
// 2 -> base
std::string _atomType;
std::string _resName;
int _resNum;

int _chainId;
};

#endif /* BEAD_H_ */
115 changes: 115 additions & 0 deletions BeadList.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
/*
* BeadList.h
*
* Created on Mar 25, 2014
* Author: Giovanni Pinamonti
*
* BeadList class.
*
*/

#ifndef BEADLIST_H_
#define BEADLIST_H_

#include <vector>
#include "Bead.h"
#include <algorithm>

class BeadList
{

private:
std::vector<std::string> _atomTypes;
std::vector<int> _resNumbers;
bool _noH;
bool _n_1_9;

public:
//creatori
BeadList():_noH(true), _n_1_9(false) {};

BeadList(std::vector<std::string> namelist):_noH(true), _n_1_9(false) {
if(namelist.size()>0){
for (int i=0;i<namelist.size();++i){

if((namelist.at(i)).compare("N1-9")==0){
_n_1_9=true;
namelist.erase(namelist.begin()+i);
cout<<")))))))))))) STRANO BEAD N1-9 ATTIVATO (((((((((((("<<endl;
}
if((namelist.at(i)).compare("ALL")==0){
namelist.erase(namelist.begin()+i);
cout<<")))))))))))) ALL ATOMS (((((((((((("<<endl;
}
}
}
_atomTypes=namelist;
return;
}

BeadList(std::vector<int> numlist):_noH(true), _n_1_9(false) {
_resNumbers=numlist;
}
/*
//funzioni
*/
void setResNum(std::vector<int> numlist){
// cout<<"cacca"<<endl;
_resNumbers=numlist;
}
void setAtomTypes(std::vector<std::string> types){
// std::vector<std::string>
_atomTypes=types;
}


inline bool check(Bead b){

// cout<<"cacca"<<endl;
// bool lacacca=true;
if((_atomTypes.size()>0)||(_n_1_9)){
bool lacacca=false;
std::string s1=b.getAtomType();
for (int i=0;i<_atomTypes.size();++i){
std::string s2=_atomTypes.at(i);
std::replace( s2.begin(), s2.end(), 'p', '\'');
// cout<<s2<<endl;
if (s1.compare(s2)==0) lacacca=true;
}
if(_n_1_9){
if( ( (b.getResName()).compare("G")==0) ||
((b.getResName()).compare("A")==0) ){
if(s1.compare("N9")==0) lacacca=true;
}
else{
if(s1.compare("N1")==0) lacacca=true;
}
}
if(!lacacca) return false;
}

if(_resNumbers.size()>0){
bool lacacca=false;
int r=b.getResNum();
for (int i=0;i<_resNumbers.size();++i){
if (r==_resNumbers.at(i)) {lacacca=true;}
}
if(!lacacca) return false;
}

// cout<<_noH<<endl;
if(_noH){
std::string s=b.getAtomType();
// cout<<s<<endl;
if (s.find("H") != std::string::npos) {
// cout<<"found!"<<endl;
return false;
}
}

return true;
}
};


#endif /* BEAD_H_ */
59 changes: 59 additions & 0 deletions Connection.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/*
* Connection.h
*
* Created on: jun 2014
* Author: g. pinamonti
*/

#ifndef CONNECTION_H_
#define CONNECTION_H_

#include "io.h"
#include <iostream>

class Connection
{
public:
Connection(int i, int j) {
_i1=i;
_i2=j;
//QUI DOVREI CONTROLLARE CHE SIANO POSITIVI E DIVERSI
}

inline int GetI1() {return _i1;}
inline int GetI2() {return _i2;}

inline bool SetI1(int i) { if((i>0)&&(i!=_i2)){ _i1=i; return true;} return false; /*CONTROLLA CHE SIANO POSITIVI E DIVERSI*/}
inline bool SetI2(int i) { if((i>0)&&(i!=_i1)){ _i2=i; return true;} return false; /*CONTROLLA CHE SIANO POSITIVI E DIVERSI*/}

private:
int _i1;
int _i2;
};


//########################################################
//### funzioni utili che utilizzano la suddetta classe ###
//########################################################

inline bool RandSwap(Connection &p,Connection &q) {
double r=((double) rand() / ((double) RAND_MAX));
if(r>0.5){
int i1=p.GetI1();
int j1=q.GetI1();
if( (p.SetI1(j1)) &&
(q.SetI1(i1)) )
return true;
}
else{
// int j2=q.GetI2();
int j1=q.GetI1();
int i2=p.GetI2();
if( (p.SetI2(j1)) &&
(q.SetI1(i2)) )
return true;
}
return false;
}

#endif /* CONNECTION_H_ */
Loading

0 comments on commit 7bc94eb

Please sign in to comment.