Last change
on this file was
2,
checked in by oldcode, 24 years ago
|
Initial revision
|
-
Property svn:eol-style set to
native
-
Property svn:keywords set to
Author Date Id Revision
|
File size:
1.7 KB
|
Line | |
---|
1 | #include "Flatio.c" |
---|
2 | #define MAX(a,b) ((a)>(b)?(a):(b)) |
---|
3 | |
---|
4 | /* |
---|
5 | * Varpos.c- An extremely simple program for showing which positions |
---|
6 | * are varying in an alignment. Use this as a model for other |
---|
7 | * external functions. |
---|
8 | * |
---|
9 | * Read in a flat file alignment, pass back an alignment color |
---|
10 | * mask. |
---|
11 | * |
---|
12 | * Copyright 1991/1992 Steven Smith, Harvard Genome lab. |
---|
13 | * |
---|
14 | */ |
---|
15 | |
---|
16 | main(ac,av) |
---|
17 | int ac; |
---|
18 | char **av; |
---|
19 | { |
---|
20 | struct data_format data[10000]; |
---|
21 | int i,j,k,numseqs,rev = FALSE; |
---|
22 | int maxlen = -99999, |
---|
23 | score = 0, |
---|
24 | minoffset = 99999; |
---|
25 | char ch; |
---|
26 | if(ac>2) |
---|
27 | { |
---|
28 | fprintf(stderr,"Usage %s [-rev]<gde_flat_file>gde_color_mask\n", av[0]); |
---|
29 | exit(1); |
---|
30 | } |
---|
31 | if(ac == 2) |
---|
32 | if(strcmp(av[1],"-rev") == 0) |
---|
33 | rev = TRUE; |
---|
34 | |
---|
35 | numseqs = ReadFlat(stdin,data,10000); |
---|
36 | |
---|
37 | if(numseqs == 0) |
---|
38 | exit(1); |
---|
39 | |
---|
40 | for(j=0;j<numseqs;j++) |
---|
41 | { |
---|
42 | if(data[j].length+data[j].offset > maxlen) |
---|
43 | maxlen = data[j].length+data[j].offset; |
---|
44 | if(data[j].offset < minoffset) |
---|
45 | minoffset = data[j].offset; |
---|
46 | } |
---|
47 | |
---|
48 | printf("length:%d\n",maxlen); |
---|
49 | printf("offset:%d\n",minoffset); |
---|
50 | printf("start:\n"); |
---|
51 | for(j=0;j<maxlen;j++) |
---|
52 | { |
---|
53 | int a=0,c=0,g=0,u=0; |
---|
54 | |
---|
55 | for(k=0;k<numseqs;k++) |
---|
56 | if(data[k].length+data[k].offset > j) |
---|
57 | { |
---|
58 | if(j>data[k].offset) |
---|
59 | ch=data[k].nuc[j-data[k].offset] | 32; |
---|
60 | else |
---|
61 | ch = '-'; |
---|
62 | |
---|
63 | if(ch=='a')a++; |
---|
64 | if(ch=='c')c++; |
---|
65 | if(ch=='g')g++; |
---|
66 | if(ch=='u')u++; |
---|
67 | if(ch=='t')u++; |
---|
68 | } |
---|
69 | |
---|
70 | score=MAX(a,c); |
---|
71 | score=MAX(score,g); |
---|
72 | score=MAX(score,u); |
---|
73 | if(a+c+g+u) |
---|
74 | { |
---|
75 | if(rev) |
---|
76 | score=(score*6/(a+c+g+u)+8); |
---|
77 | else |
---|
78 | score=((8-score*6/(a+c+g+u))+8); |
---|
79 | } |
---|
80 | else |
---|
81 | score=8; |
---|
82 | printf("%d\n",score); |
---|
83 | } |
---|
84 | exit(0); |
---|
85 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.