bool getTotalCharge( char *pqrFile, double *tCharge ) { FILE *fp; fp = fopen( pqrFile, (char *)"rt" ); if ( fp == NULL ) { printError( (char *)"Failed to open PQR file (%s)!", pqrFile ); return false; } *tCharge = 0; char line[ 101 ]; while ( fgets( line, 100, fp ) != NULL ) { int i = 0, j; char tmp[ 101 ]; i = getAlphaString( line, i, tmp ); // get 'ATOM'/'HETATM', and ignore if ( tmp[ 0 ] != 'A' ) continue; //i = getInt( line, i, &j ); // get atom number, and ignore //i = getString( line, i, tmp ); // get atom name, and ignore // don't use these either? getString1( line, tmp, 17, 3 ); // get residue name getInt1( line, &j, 22, 4 ); // get residue number double v; //i = getDouble( line, i, &v ); // get X coordinate //i = getDouble( line, i, &v ); // get Y coordinate //i = getDouble( line, i, &v ); // get Z coordinate getDouble1( line, &v, 54, 9 ); // get charge *tCharge += v; //i = getDouble( line, i, &v ); // get radius } fclose( fp ); return true; }
void LevelOneDec::setVectorsToTables() { for (size_t i = 0; i < row; ++i) { muVector.push_back(getMu(i)); alphaVector.push_back(getAlphaString(i)); } createVector2DSensReadingsLow(0.003); createVector2DSensReadingsHigh(0.003); for (size_t i = 0; i < row; ++i) { muLowerLimitVector.push_back(getMuLowerLimit(i)); muUpperLimitVector.push_back(getMuHighLimit(i)); } #ifdef _DEBUG qDebug() << "Size of mu Low:" << muLowerLimitVector.size(); qDebug() << "Size of mu High:" << muUpperLimitVector.size(); #endif avrg_mu = getAvrgMu(); avrg_alpha = getAvrgAlpha(); for (size_t i = 0; i <= row; ++i) { getMuForecast(i, 0.1); getAlphaForecast(i, 0.1); } tableLevelOneModel->setCurrencyVectors(vectorDateToLevelOne, muVector, muVectorForecast, alphaVector, alphaVectorForecast); tableStabilityLevelOneModel->setCurrencyVectors(vectorDateToLevelOne, muLowerLimitVector, muVector, muUpperLimitVector); viewTableLevelOneModel->selectRow(row); }
bool readGlycines( char *pqrFile, int *nAtm, double **atm ) { int nRes = 0, nChn = 0; RESIDUE *res = NULL; int *chn = NULL; if ( !readResidues( pqrFile, &nRes, &res, &nChn, &chn ) ) { freeMem( res ); freeMem( chn); return false; } FILE *fp; fp = fopen( pqrFile, (char *)"rt" ); if ( fp == NULL ) { printError( (char *)"Failed to open PQR file (%s)!", pqrFile ); return false; } int numAtoms = 0; char line[ 101 ]; int k = -1, l = -1; while ( fgets( line, 100, fp ) != NULL ) { int i = 0, j; char tmp[ 100 ]; i = getAlphaString( line, i, tmp ); // get 'ATOM'/'HETATM', and ignore if ( tmp[ 0 ] != 'A' ) continue; numAtoms++; } fclose( fp ); *nAtm = numAtoms; ( *atm ) = ( double * ) malloc( 5 * ( *nAtm ) * sizeof( double ) ); if ( *atm == NULL ) { printError( (char *)"Failed to allocate memory!" ); return false; } fp = fopen( pqrFile, (char *)"rt" ); if ( fp == NULL ) { printError( (char *)"Failed to open PQR file (%s)!", pqrFile ); return false; } int n = 0; k = -1; l = -1; while ( fgets( line, 100, fp ) != NULL ) { int i = 0, j; char tmp[ 100 ]; i = getAlphaString( line, i, tmp ); // get 'ATOM'/'HETATM', and ignore if ( tmp[ 0 ] != 'A' ) continue; //i = getInt( line, i, &j ); // get atom number, and ignore //i = getString( line, i, tmp ); // get atom name, and ignore getString1( line, tmp, 17, 3 ); // get residue name getInt1( line, &j, 22, 4 ); // get residue number if ( j != l ) { k++; l = j; } if ( isGXY( nRes, res, k ) || isYXG( nRes, res, k ) || ( ( k >= 1 ) && ( isGXY( nRes, res, k - 1 ) || isYXG( nRes, res, k - 1 ) ) ) || ( ( k >= 2 ) && ( isGXY( nRes, res, k - 2 ) || isYXG( nRes, res, k - 2 ) ) ) ) { double v; getDouble1( line, &v, 30, 8 ); // get X coordinate ( *atm )[ 5 * n + 0 ] = v; getDouble1( line, &v, 38, 8); // get Y coordinate ( *atm )[ 5 * n + 1 ] = v; getDouble1( line, &v, 46, 8 ); // get Z coordinate ( *atm )[ 5 * n + 2 ] = v; getDouble1( line, &v, 54, 9 ); // get charge ( *atm )[ 5 * n + 3 ] = v; getDouble1( line, &v, 63, 7 ); // get radius ( *atm )[ 5 * n + 4 ] = v; n++; } } *nAtm = n; fclose( fp ); freeMem( res ); freeMem( chn); return true; }
bool readAtomsWithResidueInfo( char *pqrFile, int *nAtm, double **atm ) { FILE *fp; fp = fopen( pqrFile, (char *)"rt" ); if ( fp == NULL ) { printError( (char *)"Failed to open PQR file (%s)!", pqrFile ); return false; } int numRes = 0; char line[ 101 ]; int l = -1, r = -1; while ( fgets( line, 100, fp ) != NULL ) { int i = 0, j; char tmp[ 100 ]; i = getAlphaString( line, i, tmp ); // get 'ATOM'/'HETATM', and ignore if ( tmp[ 0 ] != 'A' ) continue; //i = getInt( line, i, &j ); // get atom number, and ignore //i = getString( line, i, tmp ); // get atom name, and ignore getString1( line, tmp, 17, 3 ); // get residue name int resID = getResidueID( tmp ); getInt1( line, &j, 22, 4 ); // get residue number if ( ( j != l ) || ( resID != r ) ) numRes++; l = j; r = resID; } fclose( fp ); printf( (char *)"\nnumRes = %d\n", numRes ); fflush( stdout ); *nAtm = numRes; ( *atm ) = ( double * ) malloc( 5 * ( *nAtm ) * sizeof( double ) ); if ( *atm == NULL ) { printError( (char *)"Failed to allocate memory!" ); return false; } fp = fopen( pqrFile, (char *)"rt" ); if ( fp == NULL ) { printError( (char *)"Failed to open PQR file (%s)!", pqrFile ); return false; } int n = 0; l = -1; r = -1; bool done = false; while ( fgets( line, 100, fp ) != NULL ) { int i = 0, j; char tmp[ 100 ], atn[ 100 ]; i = getAlphaString( line, i, tmp ); // get 'ATOM'/'HETATM', and ignore if ( tmp[ 0 ] != 'A' ) continue; //i = getInt( line, i, &j ); // get atom number, and ignore getString1( line, atn, 12, 4 ); // get atom name getString1( line, tmp, 17, 3 ); // get residue name int resID = getResidueID( tmp ); getInt1( line, &j, 22, 4 ); // get residue number if ( ( j != l ) || ( resID != r ) ) done = false; l = j; r = resID; // arand: changed "CA" to " CA " and "CB" to " CB " to match the new method of reading data... if ( !done && ( resID != NONE ) && ( ( ( resID == GLY ) && !strcmp( atn, (char *)" CA " ) ) || ( ( resID != GLY ) && !strcmp( atn, (char *)" CB " ) ) ) ) { double v; getDouble1( line, &v, 30, 8 ); // get X coordinate ( *atm )[ 5 * n + 0 ] = v; getDouble1( line, &v, 38, 8 ); // get Y coordinate ( *atm )[ 5 * n + 1 ] = v; getDouble1( line, &v, 46, 8 ); // get Z coordinate ( *atm )[ 5 * n + 2 ] = v; ( *atm )[ 5 * n + 3 ] = resID - 1; ( *atm )[ 5 * n + 4 ] = j; n++; done = true; } } *nAtm = n; fclose( fp ); return true; }
bool readAtomsOnly( char *pqrFile, int *nAtm, double **atm ) { FILE *fp; fp = fopen( pqrFile, (char *)"rt" ); if ( fp == NULL ) { printError( (char *)"Failed to open PQR file (%s)!", pqrFile ); return false; } int numAtoms = 0; char line[ 101 ]; while ( fgets( line, 100, fp ) != NULL ) { int i = 0, j; char tmp[ 100 ]; i = getAlphaString( line, i, tmp ); // get 'ATOM'/'HETATM', and ignore if ( tmp[ 0 ] != 'A' ) continue; numAtoms++; } fclose( fp ); *nAtm = numAtoms; ( *atm ) = ( double * ) malloc( 5 * ( *nAtm ) * sizeof( double ) ); if ( *atm == NULL ) { printError( (char *)"Failed to allocate memory!" ); return false; } fp = fopen( pqrFile, (char *)"rt" ); if ( fp == NULL ) { printError( (char *)"Failed to open PQR file (%s)!", pqrFile ); return false; } int n = 0; while ( fgets( line, 100, fp ) != NULL ) { int i = 0, j; char tmp[ 100 ]; i = getAlphaString( line, i, tmp ); // get 'ATOM'/'HETATM', and ignore if ( tmp[ 0 ] != 'A' ) continue; //i = getInt( line, i, &j ); // get atom number, and ignore //i = getString( line, i, tmp ); // get atom name, and ignore getString1( line, tmp, 17, 3 ); // get residue name getInt1( line, &j, 22, 4 ); // get residue number double v; getDouble1( line, &v, 30, 8); // get X coordinate ( *atm )[ 5 * n + 0 ] = v; getDouble1( line, &v, 38, 8 ); // get Y coordinate ( *atm )[ 5 * n + 1 ] = v; getDouble1( line, &v, 46, 8 ); // get Z coordinate ( *atm )[ 5 * n + 2 ] = v; getDouble1( line, &v, 54, 9 ); // get charge ( *atm )[ 5 * n + 3 ] = v; getDouble1( line, &v, 63, 7 ); // get radius ( *atm )[ 5 * n + 4 ] = v; n++; } fclose( fp ); return true; }
bool readAtomsAndResidues( char *pqrFile, int *nAtm, double **atm, int *nRes, RESIDUE **res, int *nChn, int **chn ) { FILE *fp; fp = fopen( pqrFile, (char *)"rt" ); if ( fp == NULL ) { printError( (char *)"Failed to open PQR file (%s)!", pqrFile ); return false; } int numAtoms = 0, numRes = 0, numChains = 1; char line[ 101 ]; int l = -1; while ( fgets( line, 100, fp ) != NULL ) { int i = 0, j; char tmp[ 100 ]; char tmp1[ 100 ]; i = getAlphaString( line, i, tmp ); // get 'ATOM'/'HETATM', and ignore if ( tmp[ 0 ] != 'A' ) continue; //i = getInt( line, i, &j ); // get atom number, and ignore //i = getString( line, i, tmp ); // get atom name, and ignore //i = getAlphaString( line, i, tmp ); // get residue name, and ignore //i = getAlphaString( line, i, tmp1 ); // get residue name, and ignore getInt1( line, &j, 22, 4 ); // get residue number numAtoms++; if ( j != l ) numRes++; if ( j < l ) numChains++; l = j; } fclose( fp ); *nAtm = numAtoms; *nRes = numRes; *nChn = numChains; ( *atm ) = ( double * ) malloc( 7 * ( *nAtm ) * sizeof( double ) ); ( *res ) = ( RESIDUE * ) malloc( ( *nRes ) * sizeof( RESIDUE ) ); ( *chn ) = ( int * ) malloc( ( *nChn + 1 ) * sizeof( int ) ); if ( ( *atm == NULL ) || ( *res == NULL ) || ( *chn == NULL ) ) { printError( (char *)"Failed to allocate memory!" ); return false; } fp = fopen( pqrFile, (char *)"rt" ); if ( fp == NULL ) { printError( (char *)"Failed to open PQR file (%s)!", pqrFile ); return false; } int k = 0, n = 0, c = 1; l = -1; ( *chn )[ 0 ] = 0; while ( fgets( line, 100, fp ) != NULL ) { int i = 0, j; char tmp[ 100 ]; char tmp1[ 100 ]; i = getAlphaString( line, i, tmp ); // get 'ATOM'/'HETATM', and ignore if ( tmp[ 0 ] != 'A' ) continue; //i = getInt( line, i, &j ); // get atom number, and ignore //i = getString( line, i, tmp ); // get atom name, and ignore getString1( line, tmp, 17, 3 ); // get residue name getInt1( line, &j, 22, 4 ); // get residue number if ( j != l ) { if ( j < l ) ( *chn )[ c++ ] = k; ( *res )[ k ].resNum = j; ( *res )[ k ].chainID = c; ( *res )[ k ].resID = getResidueID( tmp ); k++; l = j; } double v; getDouble1( line, &v, 30, 8 ); // get X coordinate ( *atm )[ 7 * n + 0 ] = v; getDouble1( line, &v, 38, 8 ); // get Y coordinate ( *atm )[ 7 * n + 1 ] = v; getDouble1( line, &v, 46, 8 ); // get Z coordinate ( *atm )[ 7 * n + 2 ] = v; getDouble1( line, &v, 54, 9 ); // get charge ( *atm )[ 7 * n + 3 ] = v; getDouble1( line, &v, 63, 7 ); // get radius ( *atm )[ 7 * n + 4 ] = v; ( *atm )[ 7 * n + 5 ] = j; // residue number ( *atm )[ 7 * n + 6 ] = c; // chain number n++; } ( *chn )[ c ] = k; fclose( fp ); return true; }
bool readResidues( char *pqrFile, int *nRes, RESIDUE **res, int *nChn, int **chn ) { FILE *fp; fp = fopen( pqrFile, (char *)"rt" ); if ( fp == NULL ) { printError( (char *)"Failed to open PQR file (%s)!", pqrFile ); return false; } int numRes = 0, numChains = 1; char line[ 101 ]; int l = -1; while ( fgets( line, 100, fp ) != NULL ) { int i = 0, j; char tmp[ 100 ]; char tmp1[ 100 ]; getString1( line, tmp, 0, 6 ); // get 'ATOM'/'HETATM', and ignore if ( tmp[ 0 ] != 'A' ) continue; //i = getInt( line, i, &j ); // get atom number, and ignore //i = getString( line, i, tmp ); // get atom name, and ignore getString1( line, tmp, 17, 3 ); // get residue name, and ignore getInt1( line, &j, 22, 4 ); // get residue number if ( j != l ) numRes++; if ( j < l ) numChains++; l = j; } fclose( fp ); *nRes = numRes; *nChn = numChains; ( *res ) = ( RESIDUE * ) malloc( ( *nRes ) * sizeof( RESIDUE ) ); ( *chn ) = ( int * ) malloc( ( *nChn + 1 ) * sizeof( int ) ); if ( ( *res == NULL ) || ( *chn == NULL ) ) { printError( (char *)"Failed to allocate memory!" ); return false; } fp = fopen( pqrFile, (char *)"rt" ); if ( fp == NULL ) { printError( (char *)"Failed to open PQR file (%s)!", pqrFile ); return false; } int k = 0, c = 1; l = -1; ( *chn )[ 0 ] = 0; while ( fgets( line, 100, fp ) != NULL ) { int i = 0, j; char tmp[ 100 ]; char tmp1[ 100 ]; i = getAlphaString( line, i, tmp ); // get 'ATOM'/'HETATM', and ignore if ( tmp[ 0 ] != 'A' ) continue; // old //i = getInt( line, i, &j ); // get atom number, and ignore //i = getString( line, i, tmp ); // get atom name, and ignore getString1( line, tmp, 17, 3 ); // get residue name getInt1( line, &j, 22, 4 ); // get residue number if ( j != l ) { if ( j < l ) ( *chn )[ c++ ] = k; ( *res )[ k ].resNum = j; ( *res )[ k ].chainID = c; ( *res )[ k ].resID = getResidueID( tmp ); k++; l = j; } } ( *chn )[ c ] = k; fclose( fp ); return true; }