int main(int argc, char **argv) { char *filename = "test.pdb"; WHOLEPDB *wpdb; FILE *fp; PDB *pdb1, *pdb2, *p; int natoms; if((fp=fopen(filename, "r"))==NULL) { fprintf(stderr,"Can't open %s\n", filename); return(1); } if(((wpdb=blReadWholePDB(fp))==NULL)||(wpdb->pdb == NULL)) { fprintf(stderr,"Can't read atoms from %s\n", filename); return(1); } fclose(fp); pdb1 = wpdb->pdb; if((pdb2 = blStripHPDBAsCopy(pdb1, &natoms))==NULL) { fprintf(stderr,"Stripping hydrogens failed\n"); return(1); } if(!blCopyConects(pdb2, pdb1)) { fprintf(stderr,"Failed to copy CONECT data\n"); return(1); } printf(">>> Original CONECT data\n"); wpdb->pdb = pdb1; blWriteWholePDBTrailer(stdout, wpdb, 1); /* Reset atom numbers in original list to prove we aren't picking up the old atoms */ for(p=pdb1; p!=NULL; NEXT(p)) p->atnum = 0; printf(">>> New CONECT data\n"); wpdb->pdb = pdb2; blWriteWholePDBTrailer(stdout, wpdb, 1); return(0); }
END_TEST /* CONVERT MULTI-CHAIN PDB COMPND TO PDBML */ START_TEST(test_write_pdbml_02) { /* get pdb data */ char filename_in[] = "test_alanine_in_04.pdb", filename_example[] = "test_alanine_out_03.xml", test_message[] = "Output PDBML does not match example file."; /* force write PDBML */ FORCEXML; /* read input file */ strcat(test_input_filename,filename_in); fp = fopen(test_input_filename,"r"); wpdb = blReadWholePDB(fp); fclose(fp); ck_assert_msg(wpdb != NULL, "Failed to read PDB file."); #ifndef MS_WINDOWS /* Set temp file name */ mkstemp(test_output_filename); #endif /* Fix: Set flag for XML */ gPDBXML = TRUE; /* write output file */ fp = fopen(test_output_filename,"w"); blWriteWholePDB(fp, wpdb); fclose(fp); /* compare output file to example file */ strcat(test_example_filename, filename_example); files_identical = wholepdb_compare_files(test_example_filename, test_output_filename); /* remove output file */ remove(test_output_filename); /* return test result */ ck_assert_msg(files_identical, test_message); }
END_TEST /* Title tests */ /* =========== */ /* single-line title pdb -> pdb */ START_TEST(test_title_01) { /* get pdb data */ char filename_in[] = "test_alanine_in_02.pdb", filename_example[] = "test_alanine_in_02.pdb", test_message[] = "Output PDB does not match example file."; /* force write PDB */ FORCEPDB; /* read input file */ strcat(test_input_filename,filename_in); fp = fopen(test_input_filename,"r"); wpdb = blReadWholePDB(fp); fclose(fp); ck_assert_msg(wpdb != NULL, "Failed to read PDB file."); #ifndef MS_WINDOWS /* Set temp file name */ mkstemp(test_output_filename); #endif /* write output file */ fp = fopen(test_output_filename,"w"); blWriteWholePDB(fp, wpdb); fclose(fp); /* compare output file to example file */ strcat(test_example_filename, filename_example); files_identical = wholepdb_compare_files(test_example_filename, test_output_filename); /* remove output file */ remove(test_output_filename); /* return test result */ ck_assert_msg(files_identical, test_message); }
END_TEST /* TEST SEQRES PARSE (PDBML) */ START_TEST(test_seqres_02) { /* get pdb data */ char filename_in[] = "test_seqres_in_01.pdb", filename_example[] = "test_seqres_out_01.xml", test_message[] = "Output PDBML does not match example file."; /* force write PDBML */ FORCEXML; /* read input file */ strcat(test_input_filename,filename_in); fp = fopen(test_input_filename,"r"); wpdb = blReadWholePDB(fp); fclose(fp); ck_assert_msg(wpdb != NULL, "Failed to read PDB file."); #ifndef MS_WINDOWS /* Set temp file name */ mkstemp(test_output_filename); #endif /* write output file */ fp = fopen(test_output_filename,"w"); blWriteWholePDB(fp, wpdb); fclose(fp); /* compare output file to example file */ strcat(test_example_filename, filename_example); files_identical = wholepdb_compare_files(test_example_filename, test_output_filename); /* remove output file */ remove(test_output_filename); /* return test result */ ck_assert_msg(files_identical, test_message); }
END_TEST /* Parse PDBML - Write PDB */ START_TEST(test_read_pdbml) { /* set filename */ char filename_in[] = "test_alanine_in_01.xml"; /* set gPDBXML flag */ gPDBXML = FALSE; /* read test file */ strcat(test_input_filename,filename_in); fp = fopen(test_input_filename,"r"); wpdb = blReadWholePDB(fp); fclose(fp); /* tests */ ck_assert_msg(wpdb != NULL, "Failed to read PDB file."); ck_assert_msg(wpdb->pdb != NULL, "No atom data read from file."); ck_assert_msg(wpdb->natoms > 0, "Atom count not set."); ck_assert_msg(gPDBXML == TRUE, "PDB read flag not set."); }
WHOLEPDB *ReadWholePDB(FILE *fpin) { DEPRECATED("ReadWholePDB()","blReadWholePDB()"); return(blReadWholePDB(fpin)); }