/* ## ## ######### ## ########## ########## ### ### ## ########## ## #### #### ## ########## ## ## ## ## ## ## ## ########## ## ######## ## ## ## ## ## ## ###### ######## ## ## ## ## ## ###### ### ## ## ## ############## ## ### ## ########## ## ############## ## ### ################# ######## ## ########### ######### ## ######### ## ########### ## ## ## ### ## ########## ## ## ## ###### ## ## ########## ## ## ## ###### ######## ## # ## ## ######### ## # ## ## ## ## ## ### ########## ## ## ## ### ########## ########## ######### */ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ** ** ** ** ** E N S E M B L E ** ** ** ** Version 2.1 ** ** ** ** ** ** Principal Investigator: Julie D. Forman-Kay ** ** ** ** Author: Mickaƫl Krzeminski ** ** ** ** Date: November 2012 ** ** ** ** ** ************************************************************************************* ** ** ** ** ** Copyright (C) The Hospital for Sick Children, 2001 ** ** ** ** Distribution of substantively modified versions of this module is prohibited ** ** without the explicit permission of the copyright holder. ** ** ** ** Any use of this work or derivative works in whole or in part for any ** ** commercial purpose or for monetary gain is prohibited. ** ** ** ** ** ** NO WARRANTY ** ** This software package is provided 'as is' without warranty of any kind, ** ** expressed or implied. ** ** ** ** ** * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * \* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* COMPILATION gcc -O3 -Wall -o ss_distr ss_distr.c */ #include "Include/ens.h" enum toolsPrograms TP = __SS_DISTR__; int main(int argc, char *argv[]) { /***********************************************************\ |* *| |* *| |* Variables declaration *| |* *| |* *| \***********************************************************/ // Counters counter count, resiNb; // Initialization of the main data variable (Must always be initialized that way) PDBListData ENSData = {0, 0, NULL, NULL}; // IO files char *PDBListFileName = NULL, *outFileName = NULL; // PDB files FILE *outFile; residueList residueNbs = {0, NULL}; // Secondary structure statistics secondaryStructure statSecStr = {NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0}; /***********************************************************\ |* *| |* *| |* Arguments and Environment *| |* *| |* *| \***********************************************************/ // Checking the number of arguments if (argc < 2) { _clean_ss_distr(&ENSData, &statSecStr, &residueNbs, PDBListFileName, outFileName); __USAGE__ } for (count=1; countcount) { if (argv[count][0] == '-') { _clean_ss_distr(&ENSData, &statSecStr, &residueNbs, PDBListFileName, outFileName); fatal_error("INVALID_ARGUMENT", argv[count]); } if ((PDBListFileName = malloc((strlen(argv[count]) + 1) * CHAR_SIZE)) == NULL) { _clean_ss_distr(&ENSData, &statSecStr, &residueNbs, PDBListFileName, outFileName); fatal_error("MEMORY", "create PDBListFileName variable"); } strcpy(PDBListFileName, argv[count]); } else { _clean_ss_distr(&ENSData, &statSecStr, &residueNbs, PDBListFileName, outFileName); fatal_error("NO_ARGUMENT_FLAG", "-f"); } } else if (!strcmp(argv[count], "-o")) { ++count; if (argc>count) { if (argv[count][0] == '-') { _clean_ss_distr(&ENSData, &statSecStr, &residueNbs, PDBListFileName, outFileName); fatal_error("INVALID_ARGUMENT", argv[count]); } if ((outFileName = malloc(strlen(argv[count]) * CHAR_SIZE + 1)) == NULL) { _clean_ss_distr(&ENSData, &statSecStr, &residueNbs, PDBListFileName, outFileName); fatal_error("MEMORY", "create outFileName variable"); } strcpy(outFileName, argv[count]); } else { _clean_ss_distr(&ENSData, &statSecStr, &residueNbs, PDBListFileName, outFileName); fatal_error("NO_ARGUMENT_FLAG", "-o"); } } } if (PDBListFileName == NULL) { _clean_ss_distr(&ENSData, &statSecStr, &residueNbs, PDBListFileName, outFileName); __USAGE__; } /***********************************************************\ |* *| |* *| |* Reading PDB file list *| |* Creating distribution *| |* *| |* *| \***********************************************************/ // Recording structure coordinates if (getCoords(&ENSData, PDBListFileName, NULL)) { _clean_ss_distr(&ENSData, &statSecStr, &residueNbs, PDBListFileName, outFileName); fatal_error("A problem occured while recording coordinates from the %s list file.", PDBListFileName); } // Get the number of residues if (getResidueNumbers(&residueNbs, &ENSData)) { _clean_ss_distr(&ENSData, &statSecStr, &residueNbs, PDBListFileName, outFileName); fatal_error("A problem occured while recording residue numbers from the %s list file.", PDBListFileName); } if (!residueNbs.nb) { _clean_ss_distr(&ENSData, &statSecStr, &residueNbs, PDBListFileName, outFileName); fatal_error("A problem occured while recording residue numbers from atom headers.", NULL); } // Get the secondary structure statSecStr = getSecondaryStructure(&ENSData); if (!statSecStr.nbResidues) { _clean_ss_distr(&ENSData, &statSecStr, &residueNbs, PDBListFileName, outFileName); fatal_error("The program encountered a critical problem while attempting to get the secondary structure distribution of the ensemble!", NULL); } /***********************************************************\ |* *| |* *| |* Displaying the result *| |* *| |* *| \***********************************************************/ // Displaying the results in an elegant way if (outFileName == NULL) { outFile = stdout; } else { if ((outFile = fopen(outFileName, "w")) == NULL) { error("Impossible to open the %s file.\nThe results will be displayed on screen.\n\n", outFileName); outFile = stdout; } } /* LATER, THIS PART WILL BECOME GRAPHICAL */ fprintf(outFile, "Residue Helix Pi_Helix Helix3_10 Strand Coil Turn Bridge\n"); for (resiNb=0; resiNb