00001 #include "log.h" 00002 #include "format.h" 00003 #include "gfr.h" 00004 #include <stdio.h> 00005 00006 00007 00008 int main (int argc, char *argv[]) 00009 { 00010 GfrEntry *currGE; 00011 GfrInterRead *currGIR; 00012 int i; 00013 Stringa buffer; 00014 FILE *fp1,*fp2; 00015 int count; 00016 00017 count = 0; 00018 buffer = stringCreate (100); 00019 gfr_init ("-"); 00020 puts (gfr_writeHeader ()); 00021 while (currGE = gfr_nextEntry ()){ 00022 stringPrintf (buffer,"%s_1.bed",currGE->id); 00023 fp1 = fopen (string (buffer),"w"); 00024 stringPrintf (buffer,"%s_2.bed",currGE->id); 00025 fp2 = fopen (string (buffer),"w"); 00026 if (fp1 == NULL || fp2 == NULL) { 00027 die ("Unable to open BED files"); 00028 } 00029 fprintf (fp1,"browser full knownGene\n"); 00030 fprintf (fp1,"track name=\"Inter paird-ends: %s_1\" visibility=2\n",currGE->id); 00031 fprintf (fp2,"browser full knownGene\n"); 00032 fprintf (fp2,"track name=\"Inter paird-ends: %s_2\" visibility=2\n",currGE->id); 00033 for (i = 0; i < arrayMax (currGE->interReads); i++) { 00034 currGIR = arrp (currGE->interReads,i,GfrInterRead); 00035 fprintf (fp1,"%s\t%d\t%d\n",currGE->chromosomeTranscript1,currGIR->readStart1,currGIR->readEnd1); 00036 fprintf (fp2,"%s\t%d\t%d\n",currGE->chromosomeTranscript2,currGIR->readStart2,currGIR->readEnd2); 00037 } 00038 fclose (fp1); 00039 fclose (fp2); 00040 puts (gfr_writeGfrEntry (currGE)); 00041 count++; 00042 } 00043 gfr_deInit (); 00044 stringDestroy (buffer); 00045 warn ("%s_numGfrEntries: %d",argv[0],count); 00046 return 0; 00047 } 00048