Skip to content

Commit

Permalink
bugs fixed. deleted some files. updated the parameter files in demos
Browse files Browse the repository at this point in the history
  • Loading branch information
alexzheng42 committed Jul 27, 2020
1 parent 62b67da commit 4b1346e
Show file tree
Hide file tree
Showing 39 changed files with 4,163 additions and 2,124 deletions.
56 changes: 40 additions & 16 deletions analysis/Analysis.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,40 @@ double cellNum[4] = {0};
double cellSize[4] = {0};

char path[1024];
char names[NumofFileType][256] = {"SysInfo.dat", "", "", "out_log.txt", "out_REMD.txt", "rPBCGRO.gro", "Energy.txt", "HBInfo.txt", "AAMark.txt", "AggNum.txt", "RG.txt", "RMSD.txt", "PotMap.txt", "PotMap_T.txt", "PMFMap_T.txt"};
char obstDir[1024] = "NUll";
char names[NumofFileType][256] = {"SysInfo.dat",
"WallInfo.dat",
"ObstInfo.dat",
"CGInfo.dat",
"",
"",
"out_log.txt",
"out_REMD.txt",
"rPBCGRO.gro",
"Energy.txt",
"HBInfo.txt",
"AAMark.txt",
"AggNum.txt",
"RG.txt",
"RMSD.txt",
"PotMap.txt",
"CG2Obst.txt",
"REMD_T.txt",
"PotMap_T.txt",
"PMFMap_T.txt"};
char targetPeptideNum[16] = "";

struct FileStr **files;
struct AAStr *aminoacid;
struct PepStr *protein;
struct CGGovStr CG;
struct DisStr disInfo = {.mark = 0};
struct AtomStr *atom;
struct ConstraintStr potentialPairCollision[NATOMTYPE + 1][NATOMTYPE + 1];
struct ConstraintStr potentialPairHB[12][NATOMTYPE + 1][NATOMTYPE + 1];
struct ConstraintStr potentialPairCG[NATOMTYPE + 1][NATOMTYPE + 1];
struct HBPotentialStr HBPotential;
struct REMDStr RE = {.mark = 0, .numReplica = -1};
struct FileListStr fileList = {.count = 0};
struct FileListStr *fileList;
struct FileListStr RMSDFile = {.count = 0};
struct SectionStr *sectInfo;

Expand Down Expand Up @@ -101,10 +122,15 @@ void Initialization(int argc, const char *argv[]) {
sprintf(names[inLog], "%s", argv[i + 1]);
} else if (strcmp(argv[i], "-ref") == 0) {
while (strncmp(argv[i + RMSDFile.count + 1], "-", 1) != 0) {
sprintf(RMSDFile.list[RMSDFile.count], "%s", argv[i + (++RMSDFile.count)]);
RMSDFile.count ++;
sprintf(RMSDFile.list[RMSDFile.count - 1], "%s", argv[i + RMSDFile.count]);
}
} else if (strcmp(argv[i], "-obs") == 0) {
sprintf(obstDir, "%s", argv[i + 1]);
sprintf(names[inObst], "%s", argv[i + 1]);
} else if (strcmp(argv[i], "-dis") == 0) {
sprintf(disInfo.type, "%s", argv[i + 1]);
disInfo.mark = 1;
analysisList[CalculateRG2Obst] = 1;
} else if (strcmp(argv[i], "-nPP") == 0) {
sprintf(targetPeptideNum, "%s", argv[i + 1]);
nPP = atoi(argv[i + 1]);
Expand Down Expand Up @@ -148,29 +174,21 @@ void Initialization(int argc, const char *argv[]) {
printf(" -bHB (optional) use beta HB number as the reaction coordinate\n");
printf(" -tHB (optional) use total HB number as the reaction coordinate\n");
printf(" -rmsd (optional) use RMSD as the reaction coordinate (require -RMSD & -ref)\n");
printf(" -maxE (optional) max value of potential energy (most negative). default -150\n");
printf(" -minE (optional) min value of potential energy (least negative). default 0\n");
printf(" -maxRC (optional) max value of reaction coordinate. default 10\n");
printf(" -minRC (optional) min value of reaction coordinate. default 0\n");
printf(" -rate (optional) data dumping rate, unit is time. default 10\n");
printf(" -temp (optional) target temperature. default 300\n");
printf(" -st (optional) start frame of analyzing. default 0\n");
printf(" -et (optional) end frame of analyzing. default -1 (the final frame)\n");
exit(EXIT_SUCCESS);
} else {
if (!(strcmp(argv[i], "-bin") == 0 ||
strcmp(argv[i], "-maxE") == 0 ||
strcmp(argv[i], "-minE") == 0 ||
strcmp(argv[i], "-rate") == 0 ||
strcmp(argv[i], "-temp") == 0 ||
strcmp(argv[i], "-st") == 0 ||
strcmp(argv[i], "-et") == 0 ||
strcmp(argv[i], "-aHB") == 0 ||
strcmp(argv[i], "-bHB") == 0 ||
strcmp(argv[i], "-tHB") == 0 ||
strcmp(argv[i], "-rmsd") == 0 ||
strcmp(argv[i], "-minRC") == 0 ||
strcmp(argv[i], "-maxRC") == 0)) {
strcmp(argv[i], "-rmsd") == 0)) {
printf ("!!ERROR!!: invalid flag: %s!\n %s:%i", argv[i], __FILE__, __LINE__);
exit(EXIT_FAILURE);
}
Expand Down Expand Up @@ -204,9 +222,11 @@ void DoAnalysis(int argc, const char *argv[]) {

SystemInformationInput(i);
AssignFileList(i);
ReadLog();
ReadLog(i);
EstCell();

if (CG.mark) ReadCGPot(i);

for (int n = 1; n < NumofElem; n ++) {
if (analysisList[n]) {
switch (n) {
Expand All @@ -229,7 +249,11 @@ void DoAnalysis(int argc, const char *argv[]) {
case CalculateRG:
RGInfo(i);
break;


case CalculateRG2Obst:
DisInfo(i);
break;

case CalculateMSD:
break;

Expand Down
46 changes: 36 additions & 10 deletions analysis/Analysis.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#define TRUE 1
#define FALSE 0
#define INVALID -111
#define INFINIT 1E8
#define NATOMTYPE 32
#define BOLTZMANN 0.0019872041 //kcal / mol / K

Expand Down Expand Up @@ -49,35 +50,35 @@ list2[num]=list1; \
(((num1) > (num2)) ? (((num1) > (num3)) ? (num1) : (num3)) : \
(((num2) > (num3)) ? (num2) : (num3)))

#define transfer_vector(recv, send) \
#define TRANSFER_VECTOR(recv, send) \
recv[1]=send[1]; \
recv[2]=send[2]; \
recv[3]=send[3];

#define dotminus(n1, n2, out) \
#define DOT_MINUS(n1, n2, out) \
out[1]=n1[1]-n2[1]; \
out[2]=n1[2]-n2[2]; \
out[3]=n1[3]-n2[3];

#define dotplus(n1, n2, out) \
#define DOT_PLUS(n1, n2, out) \
out[1]=n1[1]+n2[1]; \
out[2]=n1[2]+n2[2]; \
out[3]=n1[3]+n2[3];

#define crossprod(n1, n2, result) \
#define CROSS_PROD(n1, n2, result) \
result[1]=n1[2]*n2[3]-n1[3]*n2[2]; \
result[2]=n1[3]*n2[1]-n1[1]*n2[3]; \
result[3]=n1[1]*n2[2]-n1[2]*n2[1];

#define factorprod(factor, vector, out) \
#define FACTOR_PROD(factor, vector, out) \
out[1]=factor*vector[1]; \
out[2]=factor*vector[2]; \
out[3]=factor*vector[3];

#define dotprod(n1, n2) \
#define DOT_PROD(n1, n2) \
n1[1]*n2[1]+n1[2]*n2[2]+n1[3]*n2[3];

#define pointToStruct(pointer, struct) \
#define POINT_TO_STRUCT(pointer, struct) \
pointer=&struct[0];

#define INT_2CALLOC(name, size1, size2) \
Expand Down Expand Up @@ -111,6 +112,7 @@ enum EOperation {
AnalyzeRamach,
AnalyzeConMap,
CalculateRG,
CalculateRG2Obst,
CalculateMSD,
CalculateRMSD,
CalculatePotMap,
Expand All @@ -119,6 +121,9 @@ enum EOperation {

enum EFileType {
inSys,
inWall,
inObst,
inCG,
inTrj,
inCnt,
inLog,
Expand All @@ -131,6 +136,8 @@ enum EFileType {
outRG,
outRMSD,
outPotMap,
outCG2Obst,
outREMD_T,
outPotMap_T,
outPMFMap_T,
NumofFileType
Expand Down Expand Up @@ -258,6 +265,17 @@ struct AAStr {
double mass;
};

struct CGGovStr {
char type[2][16];
int mark;
int totalNum;
};

struct DisStr {
char type[256];
int mark;
};

struct PepStr {
int startAtomNum;
int endAtomNum;
Expand Down Expand Up @@ -411,19 +429,21 @@ extern double cellSize[4];

extern char path[1024];
extern char names[NumofFileType][256];
extern char obstDir[1024];
extern char targetPeptideNum[16];

extern struct FileStr **files;
extern struct AAStr *aminoacid;
extern struct PepStr *protein;
extern struct CGGovStr CG;
extern struct DisStr disInfo;
extern struct AtomStr *atom;
extern struct HBType HBSum;
extern struct ConstraintStr potentialPairCollision[NATOMTYPE + 1][NATOMTYPE + 1];
extern struct ConstraintStr potentialPairHB[12][NATOMTYPE + 1][NATOMTYPE + 1];
extern struct ConstraintStr potentialPairCG[NATOMTYPE + 1][NATOMTYPE + 1];
extern struct HBPotentialStr HBPotential;
extern struct REMDStr RE;
extern struct FileListStr fileList;
extern struct FileListStr *fileList;
extern struct FileListStr RMSDFile;
extern struct SectionStr *sectInfo;
extern struct EnergyReadStr energy;
Expand All @@ -432,12 +452,16 @@ extern struct RMSDReadStr rmsd;

void InitializeFiles(int row, int column);
void SystemInformationInput(int id);
void ReadObst(int id, int sectNum);
void ReadWall(int id, int sectNum);
void ReadCGPot(int id);
void AdjustPBC(int id);
void FreeVariables(void);
void HBInfo(int id);
void ClusterInfo(int id);
void EnergyInfo(int id);
void RGInfo(int id);
void DisInfo(int id);
void RMSDInfo(int id);
void PESurfaceInfo(int id);
void PESurfaceInfoPerT(void);
Expand All @@ -447,12 +471,14 @@ void PrintProcess(long step);
void AssignFileList(int id);
void FindTargetFile(char *oldName, char *fileListName, char *newName);
void REMDPESurfaceCombine(void);
int ReadLog(void);
void PrintStep(struct StepPotenStr *thisStep);
int ReadLog(int id);
int ReadGro(FILE *inputFile);
int ReadConnectionMap(FILE *inputFile);
int WHAM(int argc, const char * argv[]);
int CheckHBConnection(int thisAtomNum);
int AtomModel(char *type);
int AAModel(char *type);
int ReadEnergyFile(FILE *EnergyInputFile, struct EnergyReadStr *thisE);
int ReadHBFile(FILE *HBInputFile, struct HBReadStr *thisHB);
int ReadRMSDFile(FILE *RMSDInputFile, struct RMSDReadStr *thisRMSD);
Expand Down
12 changes: 6 additions & 6 deletions analysis/Cluster.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ void CalCluster(int id) {
exit(EXIT_FAILURE);
}

for (int sectNum = 0; sectNum < fileList.count; sectNum ++) {
for (int sectNum = 0; sectNum < fileList[id].count; sectNum ++) {
memset(buffer, '\0', sizeof(buffer));
FindTargetFile(files[inCnt][id].name, fileList.list[sectNum + 1], buffer);
FindTargetFile(files[inCnt][id].name, fileList[id].list[sectNum + 1], buffer);

sprintf(directory, "%s%s", path, buffer);
inputCntFile = fopen(directory, "r");
Expand Down Expand Up @@ -146,10 +146,10 @@ int CheckInteraction (struct AtomStr *atom1, struct AtomStr *atom2, int **connec
double r_ij[4], distance2;
double range = cutoffr * cutoffr;

transfer_vector(position_i, atom1->dynamic->coordinate);
transfer_vector(position_j, atom2->dynamic->coordinate);
dotminus(position_i, position_j, r_ij);
distance2 = dotprod(r_ij, r_ij);
TRANSFER_VECTOR(position_i, atom1->dynamic->coordinate);
TRANSFER_VECTOR(position_j, atom2->dynamic->coordinate);
DOT_MINUS(position_i, position_j, r_ij);
distance2 = DOT_PROD(r_ij, r_ij);

if (distance2 < range || (connection[target_i][target_j] & HBConnect)) {
return 1;
Expand Down
Loading

0 comments on commit 4b1346e

Please sign in to comment.