static void find_positions (bool *revcompp, Genomicpos_T *leftposition, Genomicpos_T *rightposition, Genomicpos_T *startposition, Genomicpos_T *endposition, Genomicpos_T *truelength, int *contigtype, char *accession, IIT_T contig_iit) { int index; Interval_T interval; char firstchar; if ((index = IIT_find_one(contig_iit,accession)) == -1) { fprintf(stderr,"Can't find accession %s in contig IIT file\n", accession); exit(9); } else { interval = IIT_interval(contig_iit,index); *leftposition = Interval_low(interval); *rightposition = Interval_high(interval); if (IIT_version(contig_iit) <= 1) { firstchar = IIT_annotation_firstchar(contig_iit,index); if (firstchar == '-') { *revcompp = true; *startposition = Interval_high(interval) + 1U; *endposition = Interval_low(interval) + 1U; } else { *revcompp = false; *startposition = Interval_low(interval); *endposition = Interval_high(interval); } } else { if (Interval_sign(interval) < 0) { *revcompp = true; *startposition = Interval_high(interval) + 1U; *endposition = Interval_low(interval) + 1U; } else { *revcompp = false; *startposition = Interval_low(interval); *endposition = Interval_high(interval); } } *truelength = Interval_length(interval); *contigtype = Interval_type(interval); debug(printf("revcompp = %d, leftposition = %d, rightposition = %d, startposition = %d, endposition = %d\n", *revcompp,*leftposition,*rightposition,*startposition,*endposition)); return; } }
/* coordstart used only if centerp or tallyp is true */ static long int print_interval (Chrpos_T *lastcoord, long int total, char *divstring, Chrpos_T coordstart, Chrpos_T coordend, int index, IIT_T iit, int ndivs, int fieldint) { Interval_T interval; char *label, *annotation, *restofheader; bool allocp; if (centerp == true) { print_interval_centered(divstring,coordstart,index,iit,fieldint); return 0; } else if (tallyp == true) { total += print_interval_tally(&(*lastcoord),divstring,coordstart,coordend,index,iit,zeroesp); return total; } else if (runlengthp == true) { print_interval_runlength(&(*lastcoord),divstring,coordstart,coordend,index,iit,zeroesp); return 0; } if (annotationonlyp == false) { label = IIT_label(iit,index,&allocp); printf(">%s ",label); if (allocp == true) { FREE(label); } if (ndivs > 1) { if (divstring == NULL) { /* For example, if interval was retrieved by label */ divstring = IIT_divstring_from_index(iit,index); } printf("%s:",divstring); } debug(printf("index is %d\n",index)); interval = IIT_interval(iit,index); if (signedp == false) { printf("%u..%u",Interval_low(interval),Interval_high(interval)); } else if (Interval_sign(interval) < 0) { printf("%u..%u",Interval_high(interval),Interval_low(interval)); } else { printf("%u..%u",Interval_low(interval),Interval_high(interval)); } if (Interval_type(interval) > 0) { printf(" %s",IIT_typestring(iit,Interval_type(interval))); } #if 0 /* Unnecessary because of "\n" after restofheader below */ if (IIT_version(iit) < 5) { printf("\n"); } #endif } if (fieldint < 0) { annotation = IIT_annotation(&restofheader,iit,index,&allocp); printf("%s\n",restofheader); printf("%s",annotation); if (allocp == true) { FREE(restofheader); } } else { annotation = IIT_annotation(&restofheader,iit,index,&allocp); printf("%s\n",restofheader); if (allocp == true) { FREE(restofheader); } annotation = IIT_fieldvalue(iit,index,fieldint); printf("%s\n",annotation); FREE(annotation); } return 0; }