src/io.c
//read useful parts of charmm cor file
read useful parts of charmm cor file
read useful parts of charmm cor file
void read_charmm_cor(FILE *corfile, DCD *dcd, float **ref,
                     char **sele_cent, int elem_cent, PARSING_MODE *pmode_cent, int index_cent[], int *nsel_cent,
                     char **sele_rmsd, int elem_rmsd, PARSING_MODE *pmode_rmsd, int index_rmsd[], int *nsel_rmsd)
{
    char buff1[1024] = "", *buff2 = NULL, *buff3 = NULL;
    int differentSelection = 0;
    int i = 0, j = 0;
    while ( (i < dcd->NATOM) && (fgets(buff1, 1024, corfile) != NULL) )
    {
        buff2 = strtok(buff1, " \n\t");
        if ( buff2 != NULL && buff2[0] == '*' ) continue;
        else
        {
            buff3 = strtok(NULL, " \n\t");
            if ( buff3 == NULL )
            {
                if ( atoi(buff2) != dcd->NATOM )
                {
                    printf("Error : Number of atoms in DCD file and COR file are not the same !\n");
                    exit(CORFILE_NATOM_ERROR);
                }
                continue;
            }
            else
            {
                char *atnum = buff2, *resnum = buff3;
                char *resname, *atname;
                resname = strtok(NULL, " \n\t");
                atname = strtok(NULL, " \n\t");
                differentSelection = 0;
                for ( j = 0; j < elem_cent; j++ )
                {
                    differentSelection = find_matching_ones(sele_cent[j], pmode_cent, resname, atname, resnum, atnum);
                    if ( !differentSelection )
                    {
                        index_cent[i] = 1;
                        (*nsel_cent)++;
                    }
                }
                differentSelection = 0;
                for ( j = 0; j < elem_rmsd; j++ )
                {
                    differentSelection = find_matching_ones(sele_rmsd[j], pmode_rmsd, resname, atname, resnum, atnum);
                    if ( !differentSelection )
                    {
                        index_rmsd[i] = 1;
                        (*nsel_rmsd)++;
                    }
                }
                ref[i][0] = ( float ) atof(strtok(NULL, " \n\t"));
                ref[i][1] = ( float ) atof(strtok(NULL, " \n\t"));
                ref[i][2] = ( float ) atof(strtok(NULL, " \n\t"));
                i++;
                strtok(NULL, " \n\t");
                strtok(NULL, " \n\t");
                strtok(NULL, " \n\t");
            }
        }
        buff2 = strtok(NULL, " \n\t");
    }
}
void read_charmm_cor ( FILE * corfile , DCD * dcd , float * * ref , char * * sele_cent , int elem_cent , PARSING_MODE * pmode_cent , int index_cent [ ] , int * nsel_cent , char * * sele_rmsd , int elem_rmsd , PARSING_MODE * pmode_rmsd , int index_rmsd [ ] , int * nsel_rmsd ) { char buff1 [ 1024 ] = " " , * buff2 = NULL , * buff3 = NULL ; int differentSelection = 0 ; int i = 0 , j = 0 ; while ( ( i < dcd -> NATOM ) && ( fgets ( buff1 , 1024 , corfile ) != NULL ) ) { buff2 = strtok ( buff1 , " \n \t " ) ; if ( buff2 != NULL && buff2 [ 0 ] == ' ' ) continue ; else { buff3 = strtok ( NULL , " \n \t " ) ; if ( buff3 == NULL ) { if ( atoi ( buff2 ) != dcd -> NATOM ) { printf ( " \n " ) ; exit ( CORFILE_NATOM_ERROR ) ; } continue ; } else { char * atnum = buff2 , * resnum = buff3 ; char * resname , * atname ; resname = strtok ( NULL , " \n \t " ) ; atname = strtok ( NULL , " \n \t " ) ; differentSelection = 0 ; for ( j = 0 ; j < elem_cent ; j ++ ) { differentSelection = find_matching_ones ( sele_cent [ j ] , pmode_cent , resname , atname , resnum , atnum ) ; if ( ! differentSelection ) { index_cent [ i ] = 1 ; ( * nsel_cent ) ++ ; } } differentSelection = 0 ; for ( j = 0 ; j < elem_rmsd ; j ++ ) { differentSelection = find_matching_ones ( sele_rmsd [ j ] , pmode_rmsd , resname , atname , resnum , atnum ) ; if ( ! differentSelection ) { index_rmsd [ i ] = 1 ; ( * nsel_rmsd ) ++ ; } } ref [ i ] [ 0 ] = ( float ) atof ( strtok ( NULL , " \n \t " ) ) ; ref [ i ] [ 1 ] = ( float ) atof ( strtok ( NULL , " \n \t " ) ) ; ref [ i ] [ 2 ] = ( float ) atof ( strtok ( NULL , " \n \t " ) ) ; i ++ ; strtok ( NULL , " \n \t " ) ; strtok ( NULL , " \n \t " ) ; strtok ( NULL , " \n \t " ) ; } } buff2 = strtok ( NULL , " \n \t " ) ; } }
read useful parts of charmm cor file
read useful parts of charmm cor file
// centering selection // rmsd selection // coordinates