lib/xenshow.c

Go to the documentation of this file.
00001 /* xenshow - show a cross-species alignment. 
00002  *
00003  * This file is copyright 2002 Jim Kent, but license is hereby
00004  * granted for all use - public, private or commercial. */
00005 #include "common.h"
00006 #include "nt4.h"
00007 #include "xenalign.h"
00008 
00009 static char const rcsid[] = "$Id: xenshow.c,v 1.5 2003/05/06 07:33:44 kate Exp $";
00010 
00011 static void printMatchers(char *a, char *b, int lineSize, FILE *f)
00012 /* Print '|' where a[i] and b[i] match, ' ' where they don't */
00013 {
00014 int i;
00015 for (i=0; i<lineSize; ++i)
00016    {
00017    char c = ((a[i] == b[i]) ? '|' : ' ');
00018    fputc(c, f);
00019    }
00020 }
00021 
00022 static int nonDashCount(char *s, int size)
00023 /* Return number of characters in s[0] to s[size-1] that
00024  * aren't dashes. */
00025 {
00026 int count = 0;
00027 int i;
00028 for (i=0; i<size; ++i)
00029     if (s[i] != '-')
00030         ++count;
00031 return count;
00032 }
00033 
00034 void xenShowAli(char *qSym, char *tSym, char *hSym, int symCount, FILE *f,
00035    int qOffset, int tOffset, char qStrand, char tStrand, int maxLineSize)
00036 /* Print alignment and HMM symbols maxLineSize bases at a time to file. */
00037 {
00038 int i;
00039 int lineSize;
00040 int count;
00041 
00042 for (i=0; i<symCount; i += lineSize)
00043     {
00044     lineSize = symCount - i;
00045     if (lineSize > maxLineSize) lineSize = maxLineSize;
00046     mustWrite(f, qSym+i, lineSize);
00047     count = nonDashCount(qSym+i, lineSize);
00048     if (qStrand == '-')
00049         count = -count;
00050     qOffset += count;
00051     fprintf(f, " %9d\n", qOffset);
00052     printMatchers(qSym+i, tSym+i, lineSize, f);
00053     fputc('\n', f);
00054     mustWrite(f, tSym+i, lineSize);
00055     count = nonDashCount(tSym+i, lineSize);
00056     if (tStrand == '-')
00057         count = -count;
00058     tOffset += count;
00059     fprintf(f, " %9d\n", tOffset);
00060     mustWrite(f, hSym+i, lineSize);
00061     fputc('\n', f);
00062     fputc('\n', f);
00063     }
00064 }
00065 

Generated on Tue Dec 25 18:39:32 2007 for blat by  doxygen 1.5.2