18 for (group = 1; group <= alignment.
numgroups; group++) {
60 FILE *file = fopen(filename,
"r");
62 fprintf(stderr,
"Cannot open %s.\n", filename);
65 for (; fgets(in_line,
GBUFSIZ, file);) {
66 if (in_line[0] ==
'#' ||
72 for (j=0; j<strlen(in_line); j++) {
73 if (in_line[j] ==
'(') {
74 sscanf((
char*)&(in_line[j+1]),
"%d", &
offset);
82 in_line[0] ==
'#' ?
DNA :
84 in_line[0] ==
'"' ?
TEXT :
86 this_elem = &(data.
element[curelem]);
87 if (in_line[strlen(in_line)-1] ==
'\n')
88 in_line[strlen(in_line)-1] =
'\0';
92 else if (in_line[0] !=
'\n') {
93 size_t strl = strlen(in_line);
94 for (j=0, jj=0; j<strl; j++) {
95 if (in_line[j] !=
' ' && in_line[j] !=
'\n' && in_line[j] !=
'\t') {
96 buffer[jj++] = in_line[j];
135 fprintf(stderr,
"Warning, datatypes do not match.\n");
146 error =
ReadGen(filename, dataset);
160 static int FindType(
char *name,
int *dtype,
int *ftype) {
161 FILE *file = fopen(name,
"r");
172 if (fgets(in_line,
GBUFSIZ, file)) {
173 for (; strlen(in_line)<2 && fgets(in_line,
GBUFSIZ, file);) ;
175 if (in_line[0] ==
'#' || in_line[0] ==
'%' ||
176 in_line[0] ==
'"' || in_line[0] ==
'@')
184 file = fopen(name,
"r");
189 for (; fgets(in_line,
GBUFSIZ, file);) {
190 if (
Find(in_line,
"LOCUS")) {
195 else if (
Find(in_line,
"sequence")) {
224 if (
Find2(filen,
"gde") != 0)
227 FILE *file = fopen(filen,
"r");
252 for (j=0; j<len; j++)
253 putelem(seq, j+curlen, buffer[j]);
262 for (
int i=0; i<len; i++) {
263 buffer[i] = matrix[(
unsigned char)buffer[i]];
274 char offset_str[100], buf[100];
279 file = fopen(filename,
"w");
281 Warning(
"Cannot open file for output");
289 sprintf(offset_str,
"(%d)", offset+aln.
rel_offset);
291 offset_str[0] =
'\0';
294 fprintf(file,
"%c%s%s\n",
295 seqs[j].elementtype ==
DNA ?
'#' :
296 seqs[j].elementtype ==
RNA ?
'#' :
297 seqs[j].elementtype ==
PROTEIN ?
'%' :
298 seqs[j].elementtype ==
TEXT ?
'"' :
299 seqs[j].elementtype ==
MASK ?
'@' :
'"',
301 (offset+aln.
rel_offset == 0) ?
"" : offset_str);
303 if (seqs[j].tmatrix) {
304 for (k=0, kk=0; kk<seqs[j].
seqlen; kk++) {
305 if ((k)%60 == 0 && k>0) {
310 buf[k%60] = ((
char)seqs[j].tmatrix[(
int)
getelem(&(seqs[j]), kk+offset)]);
315 for (k=0, kk=0; kk<seqs[j].
seqlen; kk++) {
316 if ((k)%60 == 0 && k>0) {
321 buf[k%60] = (
getelem(&(seqs[j]), kk+offset));
325 buf[(k%60)>0 ? (k%60) : 60] =
'\0';
int Default_NAColor_LKUP[]
void LoadData(char *filen, NA_Alignment &dataset)
char short_name[SIZE_SHORT_NAME]
static void ReadNA_Flat(char *filename, NA_Alignment &data)
AliDataPtr format(AliDataPtr data, const size_t wanted_len, GB_ERROR &error)
char seq_name[SIZE_SEQ_NAME]
static void Regroup(NA_Alignment &alignment)
const char * GBS_global_string(const char *templat,...)
struct TimeStamp::@1 modify
char buffer[MESSAGE_BUFFERSIZE]
void putelem(NA_Sequence *a, int b, NA_Base c)
void strcpy_truncate(char *dest, const char *source, size_t dest_size)
void AppendNA(NA_Base *buffer, int len, NA_Sequence *seq)
static void error(const char *msg)
struct TimeStamp::@1 origin
static void NormalizeOffset(NA_Alignment &aln)
static int FindType(char *name, int *dtype, int *ftype)
GB_ERROR ReadGen(char *filename, NA_Alignment &dataset)
void Warning(const char *s)
fputs(TRACE_PREFIX, stderr)
void Ascii2NA(char *buffer, int len, int matrix[16])
static GB_ERROR LoadFile(char *filename, NA_Alignment &dataset, int type, int format)
int Default_PROColor_LKUP[]
void ARB_realloc(TYPE *&tgt, size_t nelem)
int getelem(NA_Sequence *a, int b)
void aw_message(const char *msg)
char description[SIZE_DESCRIPTION]
char authority[SIZE_AUTHORITY]
void InitNASeq(NA_Sequence *seq, int type)
int Arbdb_get_curelem(NA_Alignment &dataset)
int WriteNA_Flat(NA_Alignment &aln, char *filename, int method)
GB_write_int const char s