예제 #1
0
파일: gi_go.c 프로젝트: iandonaldson/slri
Int2 Main(void)
{  
    CharPtr filename = NULL;
    Char     daytime[100];
    Int4 success = 0;
    
    DayTimeStr(daytime, TRUE, TRUE);
    
    printf("import starts. [%s]\n",  daytime);
    
    /* check command line arguments (see NCBI toolkit corelib) */
    if (!GetArgs("dbxref", NUMARGS, myargs))
    {
         printf("Main: can not get command line arguments\n");
          return 1;
    }
    else printf("Finished getting arguments\n");

    /*initialize codeBase*/
    if (!InitCodeBaseForDBXREF())
    {
        printf( "Main: InitCodeBaseForPreBIND failed.");
        error4exitTest(&codeBase); /*quits program */
        return 1;
    }
    else 
    {
        /* setCodeBaseFlagsExclNoidx */
        codeBase.accessMode=OPEN4DENY_RW;
        codeBase.autoOpen=0;
        printf("Finished init codebase with ExclNoindex.\n");
    }
    
    if ((Boolean) myargs[0].intvalue== TRUE)
    {  
        if(!MyOpenLL_GO("LL_GO", TRUE)){
            printf("OpenTables: OpenLL_GO failed.");
            success=1;
        }
        else{
            printf("LL_GO table created successfully!\n");
            if(d4close(pD4LL_GO) != r4success) success=1;
        }
    }
    
    /*import RESULT table from text file and then quit*/
    if (success==0 && myargs[4].strvalue != NULL)
    {
        filename = myargs[4].strvalue;
        printf("Import RESULT from %s.\n", filename); 

        /*cycle through the RESULT file and place info in the RESULT database*/
        if (ImportLL_GOTable(filename) != 0)
        {
            printf( "Import RESULT failed.");
            success=1;
        }

        /*diagnostic line*/
        printf("Import Finished.\n");
    }
    
    /* close codebase */
    code4close(&codeBase);
    code4initUndo(&codeBase);
    return success;
}
예제 #2
0
파일: benchtraj.c 프로젝트: MiViB/TraDES
void InitBSPLog(Int4 randseed,CharPtr sequence,Int4 tstruc)
{
	CharPtr decsequence;
	static Char pcUname[PATH_MAX]="";
	Char timedate[25];
#ifdef OS_UNIX
    struct utsname utsbuf;
#endif

    bspTempLog=BSNew(0);
    /* compute log file name */
	if (generation==0)
	    sprintf(LogOutName,"%sfold_%ld_%s_%ld_%s",CFG_local_datafilepath,(long)experiment,handle,(long)tstruc,fnamtrj);
	else
	    sprintf(LogOutName,"%sfold_%ld_%s_%ld_%s_%s_%d",CFG_local_datafilepath,(long)experiment,handle,(long)tstruc,handle,fnamtrj,generation);
    BSprintf(bspTempLog,"\nFoldtraj v%s log report",FOLDTRAJ_VERSION);
    BSprintf(bspTempLog,"\nTrajectory File: %s%s_%d",CFG_local_datafilepath,fnamtrj,generation);
    BSprintf(bspTempLog,"\tStructure File Base Name: %s_%s_%d",handle,fnamtrj,generation);
    BSprintf(bspTempLog,"\tRandom Seed: %ld\t# Generated: %ld\tStart Numbering at: %ld",randseed,STRUCS_PER_RUN,1);
    BSprintf(bspTempLog,"\tCompared to Native Structure: 1CDZ");

    decsequence=DecodeSequence(sequence,EXTAA_PARENT);
    BSprintf(bspTempLog,"\nSequence: %s",decsequence);
    decsequence=MemFree(decsequence);
    BSprintf(bspTempLog,"\nFolding Conditions:\t%ldx%ld Trajectory Distributions\t%s Random Walk\tAverage Timeout: %ld\tBackbone Error Tolerance: %4.2f\tBackbone Precision: %6.4f\tBackbone Atom Bounciness: %5.2f%%\tSidechain Atom Bounciness: %5.2f %%\tHydrogen Bumpchecking: %s\t# Rotamer Tries: %d/chi angle\tMarkov Scale Factor: %4.2f",
            TRAJDIV,TRAJDIV,WALKTYPE==WALK_CA?"C-Alpha":"Phi-Psi",TIMEOUT,BACKBONE_ERROR_TOLERANCE,
            BACKBONE_PRECISION,ATOM_BOUNCINESS_BB*100.0,ATOM_BOUNCINESS_SC*100.0,
            BUMPCHECK_HYDROGEN?"On":"Off",NUM_ROT_TRIES,MARKOV_SCALE_FACTOR);
    if (WALKTYPE!=WALK_CA && MARKOV_SCALE_FACTOR>0.0)
        ErrPostEx(SEV_ERROR,2,2,"Markov Scale Factor should be zero for non-Ca walk -- ignored");
    if (TRAJTYPE!=TRAJ_NA) {
        BSprintf(bspTempLog,"\tTrajectory Distribution: ");
        switch (TRAJTYPE) {
            case TRAJ_UNIFORM:
                BSprintf(bspTempLog,"Uniform");
                break;
            case TRAJ_STANDARD:
                BSprintf(bspTempLog,"Amino-Acid Based");
                break;
            case TRAJ_SSTRU:
                BSprintf(bspTempLog,"1-State Secondary Structure Prediction");
                break;
            case TRAJ_GOR:
                BSprintf(bspTempLog,"3-State Secondary Structure Prediction");
                break;
            default:
                BSprintf(bspTempLog,"Unknown");
        }
    }
    if (StringCmp(CONSTRAINT_FILE,""))
            BSprintf(bspTempLog,"\tConstraint file: %s",CONSTRAINT_FILE);
    BSprintf(bspTempLog,"\nSystem Information: ");
	
	if (StringLen(pcUname)==0) {
	    StringCpy(pcUname,"Not Available\n");
#ifdef OS_UNIX
	    /* use uname to get sysinfo */
		if (uname(&utsbuf)>=0) {
	        sprintf(pcUname,"%s %s %s %s %s\n",utsbuf.sysname,utsbuf.nodename,utsbuf.release,utsbuf.version,utsbuf.machine);
		}
#else
#ifdef OS_MSWIN
	    /* assume ver is available */
		if (GetMSWinVerInfo(pcUname)!=ERR_SUCCESS) {
            StringCpy(pcUname,"Not Available\n");
	
	    }       
#endif
#endif
	}
	BSWrite(bspTempLog,pcUname,StringLen(pcUname));
    DayTimeStr(timedate,TRUE,TRUE);
    BSprintf(bspTempLog,"Job started: %s\n",timedate);
    BSprintf(bspTempLog,"\nStructure\tTime(s)\tTries\tBad Backbone Tries\tCrashes\tDistant Constraint Tries (# Violations)\tChain Length\tRadius of Gyration(A)\tHydrophobics Radius of Gyration(A)\tEnd-to-end Distance(A)\tRn\tCn");
    BSprintf(bspTempLog,"\tSurface Accessibility (A^2)\tExposed Hydrophobics (A^2)");
    BSprintf(bspTempLog,"\t# Helical Residues (DSSP)\t# Extended Residues (DSSP)");
    BSprintf(bspTempLog,"\t# Extended Residues (CA-CA dist.)");
    BSprintf(bspTempLog,"\tRMSD from Native(A)");
    BSprintf(bspTempLog,"\tZhang Potential(Exclusive Window Size %d)\tBryant-Lawrence Potential(Exclusive Window Size %d)\tCrease Energy\n",ZHANG_WINDOWSIZE,BRYANT_WINDOWSIZE);
}
예제 #3
0
파일: gi_go.c 프로젝트: iandonaldson/slri
Int2 ImportLL_GOTable(CharPtr filename)
{  
    /*declarations and initializations*/
    FILE     *pFile = NULL;
    Char     line_buffer[MAXLINE];
    CharPtr  cur_line_ptr = NULL;
    
    CharPtr  gi_ptr=NULL;
    CharPtr  go_ptr=NULL;
    CharPtr  pmid_ptr=NULL;
    
    Int4     gi = 0;
    Int4     go =0;
    Int4     pmid = 0;
    CharPtr  evicode= NULL;
    
    Int2     append_status = 0;
    Int4     results_appended=0;
    Int4     result_already_found=0;
    Int4     append_error=0;
    Char     daytime[100];
    
    Int4     count=0;
    Int4     percent=0;
    Int4     step =0;
    Int4     z=0;
    Int4     max=0;
    Int4     i ;

    

    if(!OpenLL_GONoidx("LL_GO")){
        printf("OpenTables: OpenLL_GO no indexing failed.");
        return 1;   
    }
    printf("LL_GO table opened without indexing. \n");

    

    pFile = FileOpen(filename, "r");
    if (pFile == NULL)
    {
        printf("ImportResult: Failed to open file: %s.  ", filename);
        return 1;
    }

    DayTimeStr(daytime, TRUE, TRUE);
    printf("Start importing table. [%s].\n",daytime);

    cur_line_ptr = fgets(line_buffer, (size_t)100, pFile);
    
    if((Int4)myargs[1].intvalue >0 ) z = (Int4)myargs[1].intvalue;
    if((Int4)myargs[2].intvalue >0 ) max = (Int4)myargs[2].intvalue;
    step =(Int4) max/100.0;
    
    printf("start from line [ %ld ]; import [ %ld ] lines; step = [ %ld ] \n", z+1, max, step);
    
    for(i=0; i<z; i++)
    {
        fgets(line_buffer, (size_t)MAXLINE, pFile);
    }
    if(setvbuf(stdout,  NULL, _IONBF, 0))
          printf( "Couldn't turn off stdout buffer\n");
          
    printf("%ld", percent);
    while (cur_line_ptr && count < max)
    {
        /*line is split by  tabs*/
        gi_ptr =  strtok(cur_line_ptr, "\t\n");
        go_ptr =strtok(NULL, "\t\n");     
        pmid_ptr =  strtok(NULL, "\t\n");
        evicode = strtok(NULL, "\t\n");
        
        gi = (Int4)atoi(gi_ptr);
        go = (Int4)atoi(go_ptr);
        pmid = (Int4)atoi(pmid_ptr);
        
        if(gi <= 0){
            printf( "line %d: Invalid gi %d. Record skipped.\n",count+z, gi);
            continue;
        }
        if(go <= 0){
            printf( "line %d: Invalid go id: %d.Record skipped.\n", count+z, go );
            continue;
        }
        /*if(pmid <= 0){
            ErrPostEx(SEV_ERROR, 0, 0, "LL_Append2GO: Invalid pmid on record with NPID: %d.\nRecord skipped.", NPid);
            return LL_ERROR;
        }*/
        if(evicode == NULL){
            printf( "line %d: Invalid E Code . Record skipped.\n", count+z);
            continue;
        }
        /* insert record into RESULT.dbf */
        d4appendStart(pD4LL_GO, 0);
        d4blank(pD4LL_GO);

        f4assignInt(pF4LL_NP_GO, gi);
        f4assignInt(pF4LL_GOID, go);
        f4assignInt(pF4LL_PMID, pmid);
        f4assign(pF4LL_EVICODE, evicode);
                
        append_status = d4append(pD4LL_GO);
        switch(append_status){
            case r4success: 
                results_appended++;
                break;
            case r4unique:
                result_already_found++;
                break;
            default:
                printf( "ImportResult failed to append record. append_status = %d", append_status);
                append_error++;
        }
        
        count++;
        if (count%step==0) {
            percent++;
            printf("\b\b%ld", percent);
        }
        /*get the next line*/
        cur_line_ptr = fgets(line_buffer, (size_t)MAXLINE, pFile);
    }
    printf("\n==\nappended= %ld; \tpresent= %ld; error= %ld\n\n", (long) results_appended, (long) result_already_found, (long)append_error);

    /*close the file*/
    FileClose(pFile);

    DayTimeStr(daytime, TRUE, TRUE);
    printf("Finished importing RESULT table. [%s]\n",  daytime);
 
    if((Boolean)myargs[3].intvalue == TRUE) {
        printf("Start rebuilding index ... [%s]\n",  daytime);
        if(ReindexLL_GO()==FALSE){
            printf("reindex RESULT table error \n");
            return 1;
        };
        DayTimeStr(daytime, TRUE, TRUE);
        printf("Finished rebuilding index. [%s]\n",  daytime);
    }
    /* close RESULT table */
    if(d4close(pD4LL_GO) != r4success) return 1;
    
    return 0;
}