File: score.c

package info (click to toggle)
mafft 6.864-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 2,400 kB
  • sloc: ansic: 51,638; sh: 2,205; makefile: 387; ruby: 372
file content (96 lines) | stat: -rw-r--r-- 2,266 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#include "mltaln.h"

#define DEBUG 0

void arguments( int argc, char *argv[] )
{
    int c;

	ppenalty = NOTSPECIFIED;
	ppenalty_ex = NOTSPECIFIED;
	poffset = NOTSPECIFIED;
	kimuraR = NOTSPECIFIED;
	pamN = NOTSPECIFIED;
	scoremtx = NOTSPECIFIED;

    while( --argc > 0 && (*++argv)[0] == '-' )
	{
        while ( ( c = *++argv[0] ) )
		{
            switch( c )
            {
				case 'f':
					ppenalty = (int)( atof( *++argv ) * 1000 - 0.5 );
					fprintf( stderr, "ppenalty = %d\n", ppenalty );
					--argc;
					goto nextoption;
				case 'g':
					ppenalty_ex = (int)( atof( *++argv ) * 1000 - 0.5 );
					fprintf( stderr, "ppenalty_ex = %d\n", ppenalty_ex );
					--argc;
					goto nextoption;
				case 'h':
					poffset = (int)( atof( *++argv ) * 1000 - 0.5 );
					fprintf( stderr, "poffset = %d\n", poffset );
					--argc;
					goto nextoption;
				case 'k':
					kimuraR = atoi( *++argv );
					fprintf( stderr, "kimuraR = %d\n", kimuraR );
					--argc;
					goto nextoption;
				case 'D':
					scoremtx = -1;
					break;
				case 'P':
					scoremtx = 0;
					break;
                default:
                    fprintf( stderr, "illegal option %c\n", c );
                    argc = 0;
                    break;
            }
		}
		nextoption:
			;
	}
    if( argc == 1 )
    {
        cut = atof( (*argv) );
        argc--;
    }
}


int main( int ac, char **av )
{
	int nlen[M];
	static char name[M][B], **seq;
	double score;
	extern double score_calc_for_score( int, char ** );

	arguments( ac, av );

	getnumlen( stdin );
	rewind( stdin );

	seq = AllocateCharMtx( njob, nlenmax );

	readData( stdin, name, nlen, seq );

	if( !isaligned( njob, seq ) ) ErrorExit( "Not aligned." );

	constants( njob, seq );

	score = score_calc_for_score( njob, seq );
	if( scoremtx == 0 ) score += offset;

	fprintf( stdout, "score = %f\n", score );
	if     ( scoremtx ==  0 ) fprintf( stdout, "JTT %dPAM\n", pamN );
	else if( scoremtx ==  1 ) fprintf( stdout, "Dayhoff( machigai ga aru )\n" );
	else if( scoremtx ==  2 ) fprintf( stdout, "M-Y\n" );
	else if( scoremtx == -1 ) fprintf( stdout, "DNA 1:%d\n", kimuraR );

	fprintf( stdout, "gap penalty = %+6.2f, %+6.2f, %+6.2f\n", (double)ppenalty/1000, (double)ppenalty_ex/1000, (double)poffset/1000 );
	exit( 0 );
}