/* This file creates a psl file from a pairwise file */ /* Copyright 2002 Trevor Bruen */ /* This file reads a DNA alignment of two sequences and outputs a psl. */ /* It includes N count for matching bases but does not currently do anything */ /* for repmatches... */ #include #include #include #include "misc.h" #define BLOCKMAX 1000 #define MATCH 1 #define TDELETE 2 #define QDELETE 3 #define QUERY 0 #define TARGET 1 /* Variables that are set from the command line possibly*/ int query_length = 0; int target_length = 0; int offset1 = 0; int offset2 = 0; char *in_fname = NULL; char *out_fname = NULL; char *query_name = NULL; char *target_name = NULL; /* Prints out proper invocation and exits */ void print_usage(); /* Finds size of sequences and of alignment */ int find_size(FILE *in_file); /* Processes command line inputs */ void process_inputs(int argc, char ***argv); int main( int argc, char **argv) { int target_count = 0,query_count = 0,match = 0,mismatch = 0,qgapcount = 0,qgapbases = 0; int tgapcount = 0, state; int tgapbases = 0,bcount = 0,bsize = 0, repmatches = 0, ncount = 0; int query_starts[BLOCKMAX],target_starts[BLOCKMAX],bsizes[BLOCKMAX]; int Master_Count=0; int ncolumns,nrows,i,j,k; FILE *output, *input; char **seqs,c,qr,tr; process_inputs(argc,&argv); if((input = fopen(in_fname,"r")) == NULL) print_usage(); if((output = fopen(out_fname,"w")) == NULL) print_usage(); ncolumns = find_size(input); /* Allocate for proper size */ seqs = safe_alloc(2 * sizeof(char *)); /* Allocate for proper size */ for(i=0;i<2;i++) seqs[i] = safe_alloc(ncolumns * sizeof(char)); /* Read alignments */ fclose(input); if((input = fopen(in_fname,"r")) == NULL) print_usage(); for(i=0;i<2;i++) { for(j=0;jmax) { fprintf(stderr,"Error: Size of both sequences in alignment should match\n"); exit(1); } max=size; return max; } /* Processes command line inputs */ void process_inputs(int argc, char ***argv) { int adder=0; if(argc == 8) adder = 3; else if(argc == 11) adder = 6; else if(argc !=5) print_usage(); in_fname = strClone((*argv)[(1+adder)]); query_name = strClone((*argv)[(2+adder)]); target_name= strClone((*argv)[(3+adder)]); out_fname = strClone((*argv)[(4+adder)]); if(argc > 5) { if(!strcmp((*argv)[1],"-lengths")) { query_length=atoi((*argv)[2]); target_length=atoi((*argv)[3]); } if(!strcmp((*argv)[1],"-offsets")) { offset1=atoi((*argv)[2]); offset2=atoi((*argv)[3]); } if(!strcmp((*argv)[4],"-lengths")) { query_length=atoi((*argv)[5]); target_length=atoi((*argv)[6]); } if(!strcmp((*argv)[4],"-offsets")) { offset1=atoi((*argv)[5]); offset2=atoi((*argv)[6]); } } }