22 int j, count1 = 0, count2 = 0;
24 for (j=0; j<len; j++) {
25 if (((seq[j]|32) <
'z') && ((seq[j]|32) >
'a')) {
27 if (!strchr(
"ACGTUNacgtun", seq[j]))
32 return (count2 > count1/4) ?
true :
false;
53 sscanf(asciitime,
"%d%5c%d", &(a->
dd), temp, &(a->
yy));
58 if (a->
dd <0 || a->
dd > 31 || a->
yy < 0 || a->
mm > 11)
66 FILE *file = fopen(filename,
"r");
73 bool IS_REALLY_AA =
false;
77 char *gencomments =
NULp;
87 for (; fgets(in_line,
GBUFSIZ, file);) {
88 if (in_line[strlen(in_line)-1] ==
'\n') {
89 in_line[strlen(in_line)-1] =
'\0';
91 if (
Find(in_line,
"LOCUS")) {
93 this_elem = &(dataset.
element[curelem]);
94 n = sscanf(in_line,
"%s %s %s %s %s %s %s %s",
95 fields[0], fields[1], fields[2], fields[3], fields[4],
96 fields[5], fields[6], fields[7]);
101 else if (
Find(in_line,
"DNA")) {
104 else if (
Find(in_line,
"RNA")) {
107 else if (
Find(in_line,
"MASK")) {
110 else if (
Find(in_line,
"TEXT")) {
113 else if (
Find(in_line,
"PROT")) {
124 if (
Find(in_line,
"Circular")) {
130 else if (
Find(in_line,
"DEFINITION")) {
133 else if (
Find(in_line,
"AUTHOR")) {
136 else if (
Find(in_line,
" ORGANISM")) {
139 else if (
Find(in_line,
"ACCESSION")) {
142 else if (
Find(in_line,
"ORIGIN")) {
145 for (; !done && fgets(in_line,
GBUFSIZ, file);) {
146 if (in_line[0] !=
'/') {
151 else if (len+strlen(in_line) >= buflen) {
152 size_t new_buflen = buflen+
GBUFSIZ;
157 if (start_col == -1) {
158 for (start_col=0; in_line[start_col] ==
' ' || in_line[start_col] ==
'\t'; start_col++) ;
159 for (start_col++; strchr(
"1234567890", in_line[start_col]); start_col++) ;
160 for (start_col++; in_line[start_col] ==
' ' || in_line[start_col] ==
'\t'; start_col++) ;
162 for (
int j=start_col; (c = in_line[j]) !=
'\0'; j++) {
163 if ((c !=
'\n') && ((j-start_col + 1) % 11 != 0)) {
170 for (
size_t j=0; j<len; j++) buffer[j] =
'\0';
200 else if (
Find(in_line,
"ZZZZZ")) {
207 genclen = strlen(gencomments)+1;
210 genclen += strlen(in_line)+1;
212 strncat(gencomments, in_line,
GBUFSIZ);
213 strncat(gencomments,
"\n",
GBUFSIZ);
233 FILE *file = fopen(filename,
"w");
235 Warning(
"Cannot open file for output");
243 "LOCUS %10s%8d bp %4s %10s %2d%5s%4d\n",
256 if (this_elem->
seq_name[0]) fprintf(file,
" ORGANISM %s\n", this_elem->
seq_name);
257 if (this_elem->
id[0]) fprintf(file,
" ACCESSION %s\n", this_elem->
id);
261 fprintf(file,
"ORIGIN");
264 for (i=0, k=0; k<this_elem->
seqlen+this_elem->
offset; k++) {
265 if (i%60 == 0) fprintf(file,
"\n%9d", i+1);
266 if (i%10 == 0) fprintf(file,
" ");
272 for (i=0, k=0; k<this_elem->
seqlen+this_elem->
offset; k++) {
273 if (i%60 == 0) fprintf(file,
"\n%9d", i+1);
274 if (i%10 == 0) fprintf(file,
" ");
275 fprintf(file,
"%c",
getelem(this_elem, k));
279 fprintf(file,
"\n//\n");
293 tim = localtime(&clock);
295 a->
yy = tim->tm_year;
296 a->
mm = tim->tm_mon+1;
297 a->
dd = tim->tm_mday;
298 a->
hr = tim->tm_hour;
char short_name[SIZE_SHORT_NAME]
char seq_name[SIZE_SEQ_NAME]
GB_ERROR GB_IO_error(const char *action, const char *filename)
char * ARB_strdup(const char *str)
char buffer[MESSAGE_BUFFERSIZE]
void strcpy_truncate(char *dest, const char *source, size_t dest_size)
void AppendNA(NA_Base *buffer, int len, NA_Sequence *seq)
static void AsciiTime(void *b, char *asciitime)
static void error(const char *msg)
struct TimeStamp::@1 origin
void ARB_recalloc(TYPE *&tgt, size_t oelem, size_t nelem)
GB_ERROR ReadGen(char *filename, NA_Alignment &dataset)
static bool CheckType(char *seq, int len)
void Warning(const char *s)
void Ascii2NA(char *buffer, int len, int matrix[16])
int WriteGen(NA_Alignment &aln, char *filename, int method)
TYPE * ARB_calloc(size_t nelem)
int Default_PROColor_LKUP[]
void ARB_realloc(TYPE *&tgt, size_t nelem)
int getelem(NA_Sequence *a, int b)
const char * GDEmonth[12]
char description[SIZE_DESCRIPTION]
char authority[SIZE_AUTHORITY]
void InitNASeq(NA_Sequence *seq, int type)
int Arbdb_get_curelem(NA_Alignment &dataset)