File: discrim.c

package info (click to toggle)
sim4 0.0.20121010-4
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 1,744 kB
  • ctags: 505
  • sloc: ansic: 5,807; makefile: 23; sh: 15
file content (41 lines) | stat: -rw-r--r-- 759 bytes parent folder | download | duplicates (5)
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
#include "libc.h"
#include "types.h"
#include "misc.h"
#include "args.h"
#include "seq.h"
#include "dna.h"
#include "discrim.h"

#ifndef __lint
static const char rcsid[] =
"$Id: discrim.c,v 1.2 2000/06/05 22:48:19 florea Exp $";
#endif

/* DNA characters */
const uchar dchars[] = "ABCDGHKMNRSTVWXY";

static int is_dchar(int ch);

bool is_DNA(uchar *s, int len)
{
	int ACGT, i;

	for (ACGT = i = 0; i < len; ++i)
		if (strchr("ACGTNXacgtnx", s[i]))
			++ACGT;
	if (10*ACGT < 9*len) /* ACGT < 90% of len */
		return 0;
	
	for (i = 0; i < len; ++i)
		if (!is_dchar(s[i])) {
			fatalf("Illegal character '%c' in sequence file.\n", s[i]);
			exit(1);
		}
	return 1;
}

static int is_dchar(int ch)
{ 
        return !!strchr((const char*)dchars, toupper(ch));
}