lib/jointalign.c

Go to the documentation of this file.
00001 /* jointalign.c - routines for printing a joint alignment in html. 
00002  *
00003  * This file is copyright 2002 Ryan Weber, but license is hereby
00004  * granted for all use - public, private or commercial. */
00005 
00006 #include "common.h"
00007 #include "errabort.h"
00008 #include "jointalign.h"
00009 
00010 static char const rcsid[] = "$Id: jointalign.c,v 1.11 2003/05/06 07:33:43 kate Exp $";
00011 
00012 
00013 void htmlPrintJointAlignment( char *seq1, char *seq2, int columnNum, 
00014         int start, int end, char *strand )
00015 /* Print sequences 1 and 2 (assumed to be a joint alignment),
00016  * formatted for html output. Coordinates are printed based on
00017  * the start and end positions and oriented according to the
00018  * strand the sequences are on (+ or -). (NO COORDINATES YET)*/
00019 {
00020 int i;
00021 validateSeqs( seq1, seq2 );
00022 
00023 /*print the sequences with lines connecting identical residues
00024  *in columns of size columnNum*/
00025 for( i=0; i<strlen(seq1); i += columnNum )
00026     htmlPrintJointAlignmentLine(seq1, seq2, i, min(i+columnNum, strlen(seq1)));
00027 
00028 /*printf( "<tt><hr><br>%s<br>%s<br></tt>", seq1, seq2 );*/
00029 
00030 }
00031 
00032 void htmlPrintJointAlignmentLine( char *seq1, char *seq2, int start, int end)
00033 /* Prints one line of the joint alignment between seq1 and seq2,
00034  * from seq[start] to seq[end-1].*/
00035 {
00036 
00037 int i;
00038 printf("<tt>");
00039 for( i=start; i<end; i++ )
00040     printf("%c",seq1[i]);
00041 printf("<br>");
00042 for( i=start; i<end; i++ )
00043     {
00044     if(ucaseMatch( seq1[i], seq2[i] ))
00045         printf("|");
00046     else
00047         printf("&nbsp;");
00048     }
00049 printf("<br>");
00050 for( i=start; i<end; i++ )
00051     printf("%c",seq2[i]);
00052 printf("</tt>");
00053 printf("<br><br>");
00054    
00055 
00056 }
00057 
00058 boolean ucaseMatch( char a, char b )
00059 /* Case insensitive character matching */
00060 {
00061 if( toupper( a ) == toupper( b ) )
00062     return( TRUE );
00063 else 
00064     return( FALSE );
00065 }
00066 
00067 void validateSeqs( char *seq1, char *seq2 )
00068 /*Make sure sequences are the same length*/
00069 {
00070 if( strlen(seq1) != strlen(seq2) )
00071     {
00072     printf("%s<br>%s<br>", seq1, seq2 );
00073     errAbort("The sequences are not properly aligned (different lengths)<br>\n"); 
00074     }
00075 }

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