fix: April 2023 archlinux

This commit is contained in:
kuoi 2023-04-09 02:17:32 +08:00
parent a25316aa9e
commit 15feb1c6c9
4 changed files with 2341 additions and 2587 deletions

File diff suppressed because it is too large Load diff

View file

@ -1,10 +1,12 @@
#include <sys/time.h>
#include <stdio.h>
#include <malloc.h> #include <malloc.h>
#include <xview/xview.h> #include <stdio.h>
#include <sys/time.h>
#include <time.h>
#include <xview/panel.h> #include <xview/panel.h>
#include "menudefs.h" #include <xview/xview.h>
#include "defines.h" #include "defines.h"
#include "menudefs.h"
/* /*
Copyright (c) 1989-1990, University of Illinois board of trustees. All Copyright (c) 1989-1990, University of Illinois board of trustees. All
@ -19,8 +21,7 @@ Copyright (c) 1993, Steven Smith, all rights reserved.
*/ */
ReadGen(filename,dataset,type) ReadGen(filename, dataset, type) char *filename;
char *filename;
NA_Alignment *dataset; NA_Alignment *dataset;
int type; int type;
{ {
@ -39,52 +40,42 @@ int type;
ErrorOut("No such file", file = fopen(filename, "r")); ErrorOut("No such file", file = fopen(filename, "r"));
for(;fgets(Inline,GBUFSIZ,file) != 0;) for (; fgets(Inline, GBUFSIZ, file) != 0;) {
{
if (Inline[strlen(Inline) - 1] == '\n') if (Inline[strlen(Inline) - 1] == '\n')
Inline[strlen(Inline) - 1] = '\0'; Inline[strlen(Inline) - 1] = '\0';
if(Find(Inline,"LOCUS")) if (Find(Inline, "LOCUS")) {
{
curelem = dataset->numelements++; curelem = dataset->numelements++;
if(curelem == 0) if (curelem == 0) {
{ dataset->element = (NA_Sequence *)Calloc(
dataset->element=(NA_Sequence*) 5, sizeof(NA_Sequence));
Calloc(5,sizeof(NA_Sequence));
dataset->maxnumelements = 5; dataset->maxnumelements = 5;
} }
else if (curelem==dataset->maxnumelements) else if (curelem == dataset->maxnumelements) {
{
(dataset->maxnumelements) *= 2; (dataset->maxnumelements) *= 2;
dataset->element =(NA_Sequence*) dataset->element = (NA_Sequence *)Realloc(
Realloc(dataset->element, dataset->element, dataset->maxnumelements *
dataset->maxnumelements * sizeof(NA_Sequence)); sizeof(NA_Sequence));
} }
this_elem = &(dataset->element[curelem]); this_elem = &(dataset->element[curelem]);
n = sscanf(Inline,"%s %s %s %s %s %s %s %s", n = sscanf(Inline, "%s %s %s %s %s %s %s %s", fields[0],
fields[0],fields[1],fields[2],fields[3],fields[4], fields[1], fields[2], fields[3], fields[4],
fields[5], fields[6], fields[7]); fields[5], fields[6], fields[7]);
if(IS_REALLY_AA) if (IS_REALLY_AA) {
{
InitNASeq(this_elem, PROTEIN); InitNASeq(this_elem, PROTEIN);
} }
else if(Find(Inline,"DNA")) else if (Find(Inline, "DNA")) {
{
InitNASeq(this_elem, DNA); InitNASeq(this_elem, DNA);
} }
else if(Find(Inline,"RNA")) else if (Find(Inline, "RNA")) {
{
InitNASeq(this_elem, RNA); InitNASeq(this_elem, RNA);
} }
else if(Find(Inline,"MASK")) else if (Find(Inline, "MASK")) {
{
InitNASeq(this_elem, MASK); InitNASeq(this_elem, MASK);
} }
else if(Find(Inline,"TEXT")) else if (Find(Inline, "TEXT")) {
{
InitNASeq(this_elem, TEXT); InitNASeq(this_elem, TEXT);
} }
else if(Find(Inline,"PROT")) else if (Find(Inline, "PROT")) {
{
InitNASeq(this_elem, PROTEIN); InitNASeq(this_elem, PROTEIN);
} }
else else
@ -112,83 +103,93 @@ int type;
else if (Find(Inline, "ACCESSION")) else if (Find(Inline, "ACCESSION"))
strncpy(this_elem->id, &(Inline[12]), 79); strncpy(this_elem->id, &(Inline[12]), 79);
else if(Find(Inline,"ORIGIN")) else if (Find(Inline, "ORIGIN")) {
{
done = FALSE; done = FALSE;
len = 0; len = 0;
for(;done == FALSE && fgets(Inline,GBUFSIZ,file) != 0;) for (; done == FALSE &&
{ fgets(Inline, GBUFSIZ, file) != 0;) {
if(Inline[0] != '/') if (Inline[0] != '/') {
{ if (buflen == 0) {
if(buflen == 0)
{
buflen = GBUFSIZ; buflen = GBUFSIZ;
buffer = Calloc(sizeof(char), buffer = Calloc(sizeof(char),
buflen); buflen);
} }
else if (len+strlen(Inline) >= buflen) else if (len + strlen(Inline) >=
{ buflen) {
buflen += GBUFSIZ; buflen += GBUFSIZ;
buffer = Realloc(buffer, buffer = Realloc(
buffer,
sizeof(char) * buflen); sizeof(char) * buflen);
for(j=buflen-GBUFSIZ for (j = buflen - GBUFSIZ;
;j<buflen;j++) j < buflen; j++)
buffer[j] = '\0'; buffer[j] = '\0';
} }
/* /*
* Search for the fist column of data (whitespace-number-whitespace)data * Search for the fist column of
*data
*(whitespace-number-whitespace)data
*/ */
if(start_col == -1) if (start_col == -1) {
{ for (start_col = 0;
for(start_col=0; Inline[start_col] == ' ' || Inline[start_col] == ' ' ||
Inline[start_col] == '\t';start_col++); Inline[start_col] == '\t';
start_col++)
;
for(start_col++;strchr("1234567890", for (start_col++;
Inline[start_col]) != NULL;start_col++); strchr(
"1234567890",
for(start_col++; Inline[start_col] == ' ' || Inline[start_col]) !=
Inline[start_col] == '\t';start_col++); NULL;
start_col++)
;
for (start_col++;
Inline[start_col] == ' ' ||
Inline[start_col] == '\t';
start_col++)
;
} }
for(j=start_col;(c = Inline[j]) != '\0';j++) for (j = start_col;
{ (c = Inline[j]) != '\0'; j++) {
if ((c != '\n') && if ((c != '\n') &&
((j-start_col + 1) % 11 !=0)) ((j - start_col + 1) % 11 !=
0))
buffer[len++] = c; buffer[len++] = c;
} }
} }
else else {
{ AppendNA(buffer, len,
AppendNA(buffer,len,&(dataset-> &(dataset->element[curelem]));
element[curelem]));
for (j = 0; j < len; j++) for (j = 0; j < len; j++)
buffer[j] = '\0'; buffer[j] = '\0';
len = 0; len = 0;
done = TRUE; done = TRUE;
dataset->element[curelem].comments dataset->element[curelem].comments =
= gencomments; gencomments;
dataset->element[curelem].comments_len = dataset->element[curelem].comments_len =
genclen - 1; genclen - 1;
dataset->element[curelem]. dataset->element[curelem]
comments_maxlen = genclen; .comments_maxlen = genclen;
gencomments = NULL; gencomments = NULL;
genclen = 0; genclen = 0;
} }
} }
/* /*
* Test if sequence should be converted by the translation table * Test if sequence should be converted by
* If it looks like a protein... *the translation table If it looks like a protein...
*/ */
if (dataset->element[curelem].rmatrix && if (dataset->element[curelem].rmatrix &&
IS_REALLY_AA == FALSE) IS_REALLY_AA == FALSE) {
{ IS_REALLY_AA = CheckType(
IS_REALLY_AA = CheckType(dataset->element[curelem]. dataset->element[curelem].sequence,
sequence,dataset->element[curelem].seqlen); dataset->element[curelem].seqlen);
if (IS_REALLY_AA == FALSE) if (IS_REALLY_AA == FALSE)
Ascii2NA(dataset->element[curelem].sequence, Ascii2NA(
dataset->element[curelem].sequence,
dataset->element[curelem].seqlen, dataset->element[curelem].seqlen,
dataset->element[curelem].rmatrix); dataset->element[curelem].rmatrix);
else else
@ -196,31 +197,30 @@ int type;
* Force the sequence to be AA * Force the sequence to be AA
*/ */
{ {
dataset->element[curelem].elementtype = PROTEIN; dataset->element[curelem].elementtype =
dataset->element[curelem].rmatrix = NULL; PROTEIN;
dataset->element[curelem].tmatrix = NULL; dataset->element[curelem].rmatrix =
NULL;
dataset->element[curelem].tmatrix =
NULL;
dataset->element[curelem].col_lut = dataset->element[curelem].col_lut =
Default_PROColor_LKUP; Default_PROColor_LKUP;
} }
} }
} }
else if (Find(Inline,"ZZZZZ")) else if (Find(Inline, "ZZZZZ")) {
{
Cfree(gencomments); Cfree(gencomments);
genclen = 0; genclen = 0;
} }
else else {
{ if (gencomments == NULL) {
if (gencomments == NULL)
{
gencomments = String(Inline); gencomments = String(Inline);
genclen = strlen(gencomments) + 1; genclen = strlen(gencomments) + 1;
} }
else else {
{
genclen += strlen(Inline) + 1; genclen += strlen(Inline) + 1;
gencomments = Realloc(gencomments,genclen * gencomments = Realloc(gencomments,
sizeof(char)); genclen * sizeof(char));
strncat(gencomments, Inline, GBUFSIZ); strncat(gencomments, Inline, GBUFSIZ);
strncat(gencomments, "\n", GBUFSIZ); strncat(gencomments, "\n", GBUFSIZ);
} }
@ -229,13 +229,12 @@ int type;
Cfree(buffer); Cfree(buffer);
fclose(file); fclose(file);
for (j = 0; j < dataset->numelements; j++) for (j = 0; j < dataset->numelements; j++)
dataset->maxlen = MAX(dataset->maxlen, dataset->maxlen =
dataset->element[j].seqlen+dataset->element[j].offset); MAX(dataset->maxlen, dataset->element[j].seqlen +
dataset->element[j].offset);
return; return;
} }
typedef struct mya { typedef struct mya {
int yy; int yy;
int mm; int mm;
@ -257,16 +256,12 @@ AsciiTime(sA *a,char *asciitime)
sscanf(asciitime, "%d%5c%d", &(a->dd), temp, &(a->yy)); sscanf(asciitime, "%d%5c%d", &(a->dd), temp, &(a->yy));
temp[5] = '\0'; temp[5] = '\0';
for (j = 0; j < 12; j++) for (j = 0; j < 12; j++)
if(strcmp(temp,month[j]) == 0) if (strcmp(temp, month[j]) == 0) a->mm = j + 1;
a->mm = j+1; if (a->dd < 0 || a->dd > 31 || a->yy < 0 || a->mm > 11) SetTime(a);
if(a->dd <0 || a->dd > 31 || a->yy < 0 || a->mm > 11)
SetTime(a);
return; return;
} }
WriteGen(aln, filename, method, maskable) NA_Alignment *aln;
WriteGen(aln,filename,method,maskable)
NA_Alignment *aln;
char *filename; char *filename;
int method, maskable; int method, maskable;
{ {
@ -275,14 +270,11 @@ int method,maskable;
NA_Sequence *this_elem; NA_Sequence *this_elem;
extern char month[12][6]; extern char month[12][6];
char c; char c;
if(aln == NULL) if (aln == NULL) return;
return; if (aln->na_ddata == NULL) return;
if(aln->na_ddata == NULL)
return;
file = fopen(filename, "w"); file = fopen(filename, "w");
if(file == NULL) if (file == NULL) {
{
Warning("Cannot open file for output"); Warning("Cannot open file for output");
return (1); return (1);
} }
@ -293,125 +285,176 @@ int method,maskable;
aln->element[j].selected) aln->element[j].selected)
mask = j; mask = j;
for(j=0;j<aln->numelements;j++) for (j = 0; j < aln->numelements; j++) {
{ if ((aln->element[j].selected && j != mask &&
if((aln->element[j].selected && j!=mask && method != SELECT_REGION) method != SELECT_REGION) ||
||(aln->element[j].subselected && method == SELECT_REGION) (aln->element[j].subselected && method == SELECT_REGION) ||
|| (method == ALL)) (method == ALL)) {
{
this_elem = &(aln->element[j]); this_elem = &(aln->element[j]);
fprintf(file, fprintf(
file,
"LOCUS %10s%8d bp %4s %10s %2d%5s%4d\n", "LOCUS %10s%8d bp %4s %10s %2d%5s%4d\n",
this_elem->short_name,this_elem->seqlen+this_elem->offset, this_elem->short_name,
(this_elem->elementtype == DNA) ? "DNA": this_elem->seqlen + this_elem->offset,
(this_elem->elementtype ==RNA)?"RNA": (this_elem->elementtype == DNA) ? "DNA"
(this_elem->elementtype == MASK)?"MASK": : (this_elem->elementtype == RNA) ? "RNA"
(this_elem->elementtype == PROTEIN)?"PROT":"TEXT", : (this_elem->elementtype == MASK) ? "MASK"
: (this_elem->elementtype == PROTEIN) ? "PROT"
: "TEXT",
this_elem->attr & IS_CIRCULAR ? "Circular" : "", this_elem->attr & IS_CIRCULAR ? "Circular" : "",
this_elem->t_stamp.origin.dd, this_elem->t_stamp.origin.dd,
month[this_elem->t_stamp.origin.mm - 1], month[this_elem->t_stamp.origin.mm - 1],
this_elem->t_stamp.origin.yy>1900?this_elem->t_stamp.origin.yy: this_elem->t_stamp.origin.yy > 1900
this_elem->t_stamp.origin.yy+1900); ? this_elem->t_stamp.origin.yy
: this_elem->t_stamp.origin.yy + 1900);
if (this_elem->description[0]) if (this_elem->description[0])
fprintf(file,"DEFINITION %s\n",this_elem->description); fprintf(file, "DEFINITION %s\n",
this_elem->description);
if (this_elem->seq_name[0]) if (this_elem->seq_name[0])
fprintf(file," ORGANISM %s\n",this_elem->seq_name); fprintf(file, " ORGANISM %s\n",
this_elem->seq_name);
if (this_elem->id[0]) if (this_elem->id[0])
fprintf(file," ACCESSION %s\n",this_elem->id); fprintf(file, " ACCESSION %s\n",
this_elem->id);
if (this_elem->authority[0]) if (this_elem->authority[0])
fprintf(file," AUTHORS %s\n",this_elem->authority); fprintf(file, " AUTHORS %s\n",
this_elem->authority);
if (this_elem->comments) if (this_elem->comments)
fprintf(file, "%s\n", this_elem->comments); fprintf(file, "%s\n", this_elem->comments);
fprintf(file, "ORIGIN"); fprintf(file, "ORIGIN");
if(this_elem->tmatrix) if (this_elem->tmatrix) {
{ if (mask == -1) {
if(mask == -1) for (i = 0, k = 0;
{ k < this_elem->seqlen +
for(i=0,k=0;k<this_elem->seqlen+this_elem->offset;k++) this_elem->offset;
{ k++) {
if(method == SELECT_REGION) if (method == SELECT_REGION) {
{ if (aln->selection_mask
if(aln->selection_mask[k] == '1') [k] == '1') {
{
if (i % 60 == 0) if (i % 60 == 0)
fprintf(file,"\n%9d",i+1); fprintf(
file,
"\n"
"%9"
"d",
i + 1);
if (i % 10 == 0) if (i % 10 == 0)
fprintf(file," "); fprintf(
fprintf(file,"%c",this_elem->tmatrix file,
[getelem(this_elem,k)]); " ");
fprintf(
file, "%c",
this_elem->tmatrix
[getelem(
this_elem,
k)]);
i++; i++;
} }
} }
else else {
{
if (i % 60 == 0) if (i % 60 == 0)
fprintf(file,"\n%9d",i+1); fprintf(file,
"\n%9d",
i + 1);
if (i % 10 == 0) if (i % 10 == 0)
fprintf(file," "); fprintf(file,
fprintf(file,"%c",this_elem->tmatrix " ");
[getelem(this_elem,k)]); fprintf(
file, "%c",
this_elem->tmatrix
[getelem(
this_elem,
k)]);
i++; i++;
} }
} }
} }
else else {
{ for (k = 0; k < this_elem->seqlen +
for(k=0;k<this_elem->seqlen+this_elem->offset;k++) this_elem->offset;
{ k++) {
c =(char)getelem(&(aln->element[mask]),k); c = (char)getelem(
if(c != '0' && c!= '-') &(aln->element[mask]), k);
{ if (c != '0' && c != '-') {
if (k % 60 == 0) if (k % 60 == 0)
fprintf(file,"\n%9d",k+1); fprintf(file,
"\n%9d",
k + 1);
if (k % 10 == 0) if (k % 10 == 0)
fprintf(file," "); fprintf(file,
fprintf(file,"%c",this_elem->tmatrix " ");
[getelem(this_elem,k)]); fprintf(
file, "%c",
this_elem->tmatrix
[getelem(
this_elem,
k)]);
} }
} }
} }
} }
else else {
{ if (mask == -1) {
if(mask == -1) for (i = 0, k = 0;
{ k < this_elem->seqlen +
for(i=0,k=0;k<this_elem->seqlen+this_elem->offset;k++) this_elem->offset;
{ k++) {
if(method == SELECT_REGION) if (method == SELECT_REGION) {
{ if (aln->selection_mask
if(aln->selection_mask[k] == '1') [k] == '1') {
{
if (i % 60 == 0) if (i % 60 == 0)
fprintf(file,"\n%9d",i+1); fprintf(
file,
"\n"
"%9"
"d",
i + 1);
if (i % 10 == 0) if (i % 10 == 0)
fprintf(file," "); fprintf(
fprintf(file,"%c", getelem(this_elem,k)); file,
" ");
fprintf(
file, "%c",
getelem(
this_elem,
k));
i++; i++;
} }
} }
else else {
{
if (i % 60 == 0) if (i % 60 == 0)
fprintf(file,"\n%9d",i+1); fprintf(file,
"\n%9d",
i + 1);
if (i % 10 == 0) if (i % 10 == 0)
fprintf(file," "); fprintf(file,
fprintf(file,"%c",getelem(this_elem,k)); " ");
fprintf(
file, "%c",
getelem(this_elem,
k));
i++; i++;
} }
} }
} }
else else {
{ for (k = 0; k < this_elem->seqlen +
for(k=0;k<this_elem->seqlen+this_elem->offset;k++) this_elem->offset;
{ k++) {
c =(char)getelem(&(aln->element[mask]),k); c = (char)getelem(
if(c != '0' && c!= '-') &(aln->element[mask]), k);
{ if (c != '0' && c != '-') {
if (k % 60 == 0) if (k % 60 == 0)
fprintf(file,"\n%9d",k+1); fprintf(file,
"\n%9d",
k + 1);
if (k % 10 == 0) if (k % 10 == 0)
fprintf(file," "); fprintf(file,
fprintf(file,"%c",getelem(this_elem,k)); " ");
fprintf(
file, "%c",
getelem(this_elem,
k));
} }
} }
} }
@ -423,7 +466,6 @@ int method,maskable;
return; return;
} }
SetTime(sA *a) SetTime(sA *a)
{ {
struct tm *tim, *localtime(); struct tm *tim, *localtime();
@ -446,19 +488,15 @@ SetTime(sA *a)
* appears to be an amino acid sequence. If it is, pass back * appears to be an amino acid sequence. If it is, pass back
* TRUE, else FALSE. * TRUE, else FALSE.
*/ */
CheckType(seq,len) CheckType(seq, len) char *seq;
char *seq;
int len; int len;
{ {
int j, count1 = 0, count2 = 0; int j, count1 = 0, count2 = 0;
for (j = 0; j < len; j++) for (j = 0; j < len; j++)
if(((seq[j]|32) < 'z') && ((seq[j]|32) > 'a')) if (((seq[j] | 32) < 'z') && ((seq[j] | 32) > 'a')) {
{
count1++; count1++;
if(index("ACGTUNacgtun",seq[j]) == NULL) if (index("ACGTUNacgtun", seq[j]) == NULL) count2++;
count2++;
} }
return ((count2 > count1 / 4) ? TRUE : FALSE); return ((count2 > count1 / 4) ? TRUE : FALSE);

View file

@ -1,18 +1,18 @@
#include <sys/time.h>
#include <stdio.h>
#include <malloc.h> #include <malloc.h>
#include <xview/xview.h> #include <stdio.h>
#include <sys/time.h>
#include <time.h>
#include <xview/panel.h> #include <xview/panel.h>
#include "menudefs.h" #include <xview/xview.h>
#include "defines.h"
#include "defines.h"
#include "menudefs.h"
/* /*
Copyright (c) 1990,1991,1992 Steven Smith at the Harvard Genome Laboratory. Copyright (c) 1990,1991,1992 Steven Smith at the Harvard Genome Laboratory.
All rights reserved. All rights reserved.
*/ */
ReadGDE(filename,dataset,type) ReadGDE(filename, dataset, type) char *filename;
char *filename;
NA_Alignment *dataset; NA_Alignment *dataset;
int type; int type;
{ {
@ -28,171 +28,140 @@ int type;
ErrorOut("No such file", file = fopen(filename, "r")); ErrorOut("No such file", file = fopen(filename, "r"));
for(;fgets(Inline,GBUFSIZ,file) != 0;) for (; fgets(Inline, GBUFSIZ, file) != 0;) {
{ for (line = Inline; line[0] == ' ' || line[0] == '\t'; line++)
for(line = Inline;line[0]==' ' || line[0] == '\t';line++); ;
if(Find2(line,"{")==0) if (Find2(line, "{") == 0) {
{
this_elem = &temp_elem; this_elem = &temp_elem;
InitNASeq(this_elem, DNA); InitNASeq(this_elem, DNA);
this_elem->offset = -(dataset->rel_offset); this_elem->offset = -(dataset->rel_offset);
} }
else if(Find2(line,"type")==0) else if (Find2(line, "type") == 0) {
{ if (Find(line, "DNA")) {
if(Find(line,"DNA"))
{
this_elem->elementtype = DNA; this_elem->elementtype = DNA;
this_elem->tmatrix = Default_DNA_Trans; this_elem->tmatrix = Default_DNA_Trans;
this_elem->rmatrix = Default_NA_RTrans; this_elem->rmatrix = Default_NA_RTrans;
} }
else if(Find(line,"RNA")) else if (Find(line, "RNA")) {
{
this_elem->elementtype = RNA; this_elem->elementtype = RNA;
this_elem->tmatrix = Default_RNA_Trans; this_elem->tmatrix = Default_RNA_Trans;
this_elem->rmatrix = Default_NA_RTrans; this_elem->rmatrix = Default_NA_RTrans;
} }
else if(Find(line,"MASK")) else if (Find(line, "MASK")) {
{
this_elem->elementtype = MASK; this_elem->elementtype = MASK;
this_elem->rmatrix = NULL; this_elem->rmatrix = NULL;
this_elem->tmatrix = NULL; this_elem->tmatrix = NULL;
this_elem->col_lut = NULL; this_elem->col_lut = NULL;
} }
else if(Find(line,"TEXT")) else if (Find(line, "TEXT")) {
{
this_elem->elementtype = TEXT; this_elem->elementtype = TEXT;
this_elem->rmatrix = NULL; this_elem->rmatrix = NULL;
this_elem->tmatrix = NULL; this_elem->tmatrix = NULL;
this_elem->col_lut = NULL; this_elem->col_lut = NULL;
} }
else if(Find(line,"PROT")) else if (Find(line, "PROT")) {
{
this_elem->elementtype = PROTEIN; this_elem->elementtype = PROTEIN;
this_elem->rmatrix = NULL; this_elem->rmatrix = NULL;
this_elem->tmatrix = NULL; this_elem->tmatrix = NULL;
this_elem->col_lut = Default_PROColor_LKUP; this_elem->col_lut = Default_PROColor_LKUP;
} }
/* /*
this_elem->attr = DEFAULT_X_ATTR; this_elem->attr =
DEFAULT_X_ATTR;
*/ */
} }
else if(Find2(line,"circular")==0) else if (Find2(line, "circular") == 0) {
{
sscanf(line, "%*s %d", &temp); sscanf(line, "%*s %d", &temp);
if(temp == 1) if (temp == 1) {
{
this_elem->attr |= IS_CIRCULAR; this_elem->attr |= IS_CIRCULAR;
} }
else else {
{
this_elem->attr &= ~IS_CIRCULAR; this_elem->attr &= ~IS_CIRCULAR;
} }
} }
else if(Find2(line,"orig_direction")==0) else if (Find2(line, "orig_direction") == 0) {
{
sscanf(line, "%*s %d", &temp); sscanf(line, "%*s %d", &temp);
if(temp == 1) if (temp == 1) {
{
this_elem->attr |= IS_ORIG_5_TO_3; this_elem->attr |= IS_ORIG_5_TO_3;
this_elem->attr &= ~IS_ORIG_3_TO_5; this_elem->attr &= ~IS_ORIG_3_TO_5;
} }
else else {
{
this_elem->attr |= IS_ORIG_3_TO_5; this_elem->attr |= IS_ORIG_3_TO_5;
this_elem->attr &= ~IS_ORIG_5_TO_3; this_elem->attr &= ~IS_ORIG_5_TO_3;
} }
} }
else if(Find2(line,"direction")==0) else if (Find2(line, "direction") == 0) {
{
sscanf(line, "%*s %d", &temp); sscanf(line, "%*s %d", &temp);
if(temp == 1) if (temp == 1) {
{
this_elem->attr |= IS_5_TO_3; this_elem->attr |= IS_5_TO_3;
this_elem->attr &= ~IS_3_TO_5; this_elem->attr &= ~IS_3_TO_5;
} }
else else {
{
this_elem->attr |= IS_3_TO_5; this_elem->attr |= IS_3_TO_5;
this_elem->attr &= ~IS_5_TO_3; this_elem->attr &= ~IS_5_TO_3;
} }
} }
else if(Find2(line,"orig_strand")==0) else if (Find2(line, "orig_strand") == 0) {
{
sscanf(line, "%*s %d", &temp); sscanf(line, "%*s %d", &temp);
if(temp == 1) if (temp == 1) {
{
this_elem->attr |= IS_ORIG_PRIMARY; this_elem->attr |= IS_ORIG_PRIMARY;
this_elem->attr &= ~IS_ORIG_SECONDARY; this_elem->attr &= ~IS_ORIG_SECONDARY;
} }
else else {
{
this_elem->attr |= IS_ORIG_SECONDARY; this_elem->attr |= IS_ORIG_SECONDARY;
this_elem->attr &= ~IS_ORIG_PRIMARY; this_elem->attr &= ~IS_ORIG_PRIMARY;
} }
} }
else if(Find2(line,"strandedness")==0) else if (Find2(line, "strandedness") == 0) {
{
sscanf(line, "%*s %d", &temp); sscanf(line, "%*s %d", &temp);
if(temp == 1) if (temp == 1) {
{
this_elem->attr |= IS_PRIMARY; this_elem->attr |= IS_PRIMARY;
this_elem->attr &= ~IS_SECONDARY; this_elem->attr &= ~IS_SECONDARY;
} }
else else {
{
this_elem->attr |= IS_SECONDARY; this_elem->attr |= IS_SECONDARY;
this_elem->attr &= ~IS_PRIMARY; this_elem->attr &= ~IS_PRIMARY;
} }
} }
else if(Find2(line,"creator")==0) else if (Find2(line, "creator") == 0) {
{
sscanf(line, "%*s %[^\n]", this_elem->authority); sscanf(line, "%*s %[^\n]", this_elem->authority);
RemoveQuotes(this_elem->authority); RemoveQuotes(this_elem->authority);
} }
else if(Find2(line,"longname")==0) else if (Find2(line, "longname") == 0) {
{
sscanf(line, "%*s %[^\n]", this_elem->seq_name); sscanf(line, "%*s %[^\n]", this_elem->seq_name);
RemoveQuotes(this_elem->seq_name); RemoveQuotes(this_elem->seq_name);
} }
else if(Find2(line,"descrip")==0) else if (Find2(line, "descrip") == 0) {
{
sscanf(line, "%*s %[^\n]", this_elem->description); sscanf(line, "%*s %[^\n]", this_elem->description);
RemoveQuotes(this_elem->description); RemoveQuotes(this_elem->description);
} }
else if(Find2(line,"name")==0) else if (Find2(line, "name") == 0) {
{
sscanf(line, "%*s %[^\n]", this_elem->short_name); sscanf(line, "%*s %[^\n]", this_elem->short_name);
RemoveQuotes(this_elem->short_name); RemoveQuotes(this_elem->short_name);
} }
else if(Find2(line,"group-ID")==0) else if (Find2(line, "group-ID") == 0) {
{
sscanf(line, "%*s %d", &(this_elem->groupid)); sscanf(line, "%*s %d", &(this_elem->groupid));
dataset->numgroups = dataset->numgroups =
MAX(this_elem->groupid, dataset->numgroups); MAX(this_elem->groupid, dataset->numgroups);
} }
else if(Find2(line,"sequence-ID")==0) else if (Find2(line, "sequence-ID") == 0) {
{
sscanf(line, "%*s %[^\n]", this_elem->id); sscanf(line, "%*s %[^\n]", this_elem->id);
RemoveQuotes(this_elem->id); RemoveQuotes(this_elem->id);
} }
else if(Find2(line,"barcode")==0) else if (Find2(line, "barcode") == 0) {
{
sscanf(line, "%*s %[^\n]", this_elem->barcode); sscanf(line, "%*s %[^\n]", this_elem->barcode);
RemoveQuotes(this_elem->barcode); RemoveQuotes(this_elem->barcode);
} }
else if(Find2(line,"membrane")==0) else if (Find2(line, "membrane") == 0) {
{
sscanf(line, "%*s %[^\n]", this_elem->membrane); sscanf(line, "%*s %[^\n]", this_elem->membrane);
RemoveQuotes(this_elem->membrane); RemoveQuotes(this_elem->membrane);
} }
else if(Find2(line,"contig")==0) else if (Find2(line, "contig") == 0) {
{
sscanf(line, "%*s %[^\n]", this_elem->contig); sscanf(line, "%*s %[^\n]", this_elem->contig);
RemoveQuotes(this_elem->contig); RemoveQuotes(this_elem->contig);
} }
else if(Find2(line,"creation-date")==0) else if (Find2(line, "creation-date") == 0) {
{
sscanf(line, "%*s %2d%*c%2d%*c%2d%*c%2d%*c%2d%*c%2d\n", sscanf(line, "%*s %2d%*c%2d%*c%2d%*c%2d%*c%2d%*c%2d\n",
&(this_elem->t_stamp.origin.mm), &(this_elem->t_stamp.origin.mm),
&(this_elem->t_stamp.origin.dd), &(this_elem->t_stamp.origin.dd),
@ -201,13 +170,11 @@ int type;
&(this_elem->t_stamp.origin.mn), &(this_elem->t_stamp.origin.mn),
&(this_elem->t_stamp.origin.sc)); &(this_elem->t_stamp.origin.sc));
} }
else if(Find2(line,"offset")==0) else if (Find2(line, "offset") == 0) {
{
sscanf(line, "%*s %d", &(this_elem->offset)); sscanf(line, "%*s %d", &(this_elem->offset));
this_elem->offset -= dataset->rel_offset; this_elem->offset -= dataset->rel_offset;
} }
else if(Find2(line,"comments")==0) else if (Find2(line, "comments") == 0) {
{
if (this_elem->comments_maxlen == 0) if (this_elem->comments_maxlen == 0)
buflen = 2048; buflen = 2048;
else else
@ -221,17 +188,16 @@ int type;
ErrorOut(0, "Error in input file"); ErrorOut(0, "Error in input file");
line++; line++;
buffer = Calloc(buflen, sizeof(char)); buffer = Calloc(buflen, sizeof(char));
for(;!done;) for (; !done;) {
{ for (j = 0; j < strlen(line); j++) {
for(j=0;j<strlen(line);j++) if (len + strlen(line) >= buflen) {
{
if(len+strlen(line) >= buflen)
{
buflen *= 2; buflen *= 2;
buffer = Realloc(buffer, buffer = Realloc(
buffer,
buflen * sizeof(char)); buflen * sizeof(char));
} }
if(line[j] == '"') done = TRUE; if (line[j] == '"')
done = TRUE;
else else
buffer[len++] = line[j]; buffer[len++] = line[j];
@ -240,8 +206,7 @@ int type;
* Check pad with null * Check pad with null
*/ */
buffer[len] = '\0'; buffer[len] = '\0';
if(!done) if (!done) {
{
if (fgets(Inline, GBUFSIZ, file) == 0) if (fgets(Inline, GBUFSIZ, file) == 0)
done = TRUE; done = TRUE;
line = Inline; line = Inline;
@ -252,8 +217,7 @@ int type;
this_elem->comments_maxlen = buflen; this_elem->comments_maxlen = buflen;
RemoveQuotes(this_elem->comments); RemoveQuotes(this_elem->comments);
} }
else if(Find2(line,"sequence")==0) else if (Find2(line, "sequence") == 0) {
{
buflen = GBUFSIZ; buflen = GBUFSIZ;
done = FALSE; done = FALSE;
len = 0; len = 0;
@ -264,36 +228,36 @@ int type;
ErrorOut(0, "Error in input file"); ErrorOut(0, "Error in input file");
line++; line++;
for(;!done;) for (; !done;) {
{ for (j = 0; j < strlen(line); j++) {
for(j=0;j<strlen(line);j++) if (len + strlen(line) >= buflen) {
{
if(len+strlen(line) >= buflen)
{
buflen *= 2; buflen *= 2;
buffer = Realloc(buffer, buffer = Realloc(
buffer,
buflen * sizeof(char)); buflen * sizeof(char));
} }
if(line[j] == '"') done = TRUE; if (line[j] == '"')
done = TRUE;
else else {
{
/* /*
* If not text, ignore spaces... * If not
*text, ignore spaces...
*/ */
if(this_elem->elementtype !=TEXT) if (this_elem->elementtype !=
{ TEXT) {
if(line[j]!=' ' && line[j] != if (line[j] != ' ' &&
'\t' && line[j] != '\n') line[j] != '\t' &&
buffer[len++] = line[j]; line[j] != '\n')
buffer[len++] =
line[j];
} }
else else if (line[j] != '\t' &&
if(line[j] != '\t' && line[j] != '\n') line[j] != '\n')
buffer[len++] = line[j]; buffer[len++] = line[j];
} }
} }
if(!done) if (!done) {
{
if (fgets(Inline, GBUFSIZ, file) == 0) if (fgets(Inline, GBUFSIZ, file) == 0)
done = TRUE; done = TRUE;
line = Inline; line = Inline;
@ -301,67 +265,62 @@ int type;
} }
if (this_elem->rmatrix) if (this_elem->rmatrix)
for (j = 0; j < len; j++) for (j = 0; j < len; j++)
buffer[j]=this_elem->rmatrix[buffer[j]]; buffer[j] =
this_elem->rmatrix[buffer[j]];
this_elem->sequence = (NA_Base *)buffer; this_elem->sequence = (NA_Base *)buffer;
this_elem->seqlen = len; this_elem->seqlen = len;
this_elem->seqmaxlen = buflen; this_elem->seqmaxlen = buflen;
} }
else if (Find2(line,"}")==0) else if (Find2(line, "}") == 0) {
{
if (this_elem->id[0] == '\0') if (this_elem->id[0] == '\0')
strncpy(this_elem->id, uniqueID(), 79); strncpy(this_elem->id, uniqueID(), 79);
if (this_elem->short_name[0] == '\0') if (this_elem->short_name[0] == '\0')
strncpy(this_elem->short_name,this_elem->id,79); strncpy(this_elem->short_name, this_elem->id,
79);
if (this_elem->seqlen == 0) if (this_elem->seqlen == 0)
this_elem->protect = this_elem->protect =
PROT_BASE_CHANGES+ PROT_BASE_CHANGES + PROT_GREY_SPACE +
PROT_GREY_SPACE+ PROT_WHITE_SPACE + PROT_TRANSLATION;
PROT_WHITE_SPACE+
PROT_TRANSLATION;
genclen = 0; genclen = 0;
/* /*
* Make a new sequence entry... * Make a new sequence entry...
*/ */
success = -1; success = -1;
if(OVERWRITE) if (OVERWRITE) success = OverWrite(this_elem, dataset);
success = OverWrite(this_elem,dataset);
if(success == -1) if (success == -1) {
{
curelem = dataset->numelements++; curelem = dataset->numelements++;
if(curelem == 0) if (curelem == 0) {
{ dataset->element =
dataset->element=(NA_Sequence*) (NA_Sequence *)Calloc(
Calloc(5,sizeof(NA_Sequence)); 5, sizeof(NA_Sequence));
dataset->maxnumelements = 5; dataset->maxnumelements = 5;
} }
else if (curelem==dataset->maxnumelements) else if (curelem == dataset->maxnumelements) {
{
(dataset->maxnumelements) *= 2; (dataset->maxnumelements) *= 2;
dataset->element =(NA_Sequence*) dataset->element =
Realloc(dataset->element, (NA_Sequence *)Realloc(
dataset->maxnumelements * sizeof(NA_Sequence)); dataset->element,
dataset->maxnumelements *
sizeof(NA_Sequence));
} }
dataset->element[curelem] = *this_elem; dataset->element[curelem] = *this_elem;
} }
} }
else if(this_elem != NULL) else if (this_elem != NULL) {
{ if (this_elem->baggage == NULL) {
if (this_elem->baggage == NULL)
{
this_elem->baggage = String(line); this_elem->baggage = String(line);
this_elem->baggage_maxlen = this_elem->baggage_maxlen =
this_elem->baggage_len = this_elem->baggage_len =
strlen(this_elem->baggage) + 1; strlen(this_elem->baggage) + 1;
} }
else else {
{
this_elem->baggage_len += strlen(line) + 1; this_elem->baggage_len += strlen(line) + 1;
this_elem->baggage = Realloc( this_elem->baggage = Realloc(
this_elem->baggage,this_elem->baggage_len * this_elem->baggage,
sizeof(char)); this_elem->baggage_len * sizeof(char));
this_elem->baggage_maxlen = this_elem->baggage_maxlen =
this_elem->baggage_len; this_elem->baggage_len;
@ -377,8 +336,7 @@ int type;
return; return;
} }
WriteGDE(aln,filename,method,maskable) WriteGDE(aln, filename, method, maskable) NA_Alignment *aln;
NA_Alignment *aln;
char *filename; char *filename;
int method, maskable; int method, maskable;
{ {
@ -387,14 +345,11 @@ int method,maskable;
NA_Sequence *this_elem; NA_Sequence *this_elem;
extern char month[12][6]; extern char month[12][6];
if(aln == NULL) if (aln == NULL) return;
return; if (aln->na_ddata == NULL) return;
if(aln->na_ddata == NULL)
return;
file = fopen(filename, "w"); file = fopen(filename, "w");
if(file == NULL) if (file == NULL) {
{
Warning("Cannot open file for output"); Warning("Cannot open file for output");
return (1); return (1);
} }
@ -405,76 +360,95 @@ int method,maskable;
aln->element[j].selected) aln->element[j].selected)
mask = j; mask = j;
for(j=0;j<aln->numelements;j++) for (j = 0; j < aln->numelements; j++) {
{ if ((aln->element[j].selected && j != mask &&
if((aln->element[j].selected && j!=mask && method!=SELECT_REGION) method != SELECT_REGION) ||
|| (method == ALL) (method == ALL) ||
|| (aln->element[j].subselected && method == SELECT_REGION)) (aln->element[j].subselected && method == SELECT_REGION)) {
{
this_elem = &(aln->element[j]); this_elem = &(aln->element[j]);
SeqNorm(this_elem); SeqNorm(this_elem);
fprintf(file, "{\n"); fprintf(file, "{\n");
if (this_elem->short_name[0]) if (this_elem->short_name[0])
fprintf(file,"name \"%s\"\n",this_elem->short_name); fprintf(file, "name \"%s\"\n",
switch(this_elem->elementtype) this_elem->short_name);
{ switch (this_elem->elementtype) {
case DNA: case DNA:
fprintf(file,"type \"DNA\"\n"); fprintf(file,
"type \"DNA\"\n");
break; break;
case RNA: case RNA:
fprintf(file,"type \"RNA\"\n"); fprintf(file,
"type \"RNA\"\n");
break; break;
case PROTEIN: case PROTEIN:
fprintf(file,"type \"PROTEIN\"\n"); fprintf(file,
"type \"PROTEIN\"\n");
break; break;
case MASK: case MASK:
fprintf(file,"type \"MASK\"\n"); fprintf(file,
"type \"MASK\"\n");
break; break;
case TEXT: case TEXT:
fprintf(file,"type \"TEXT\"\n"); fprintf(file,
"type \"TEXT\"\n");
break; break;
} }
if (this_elem->seq_name[0]) if (this_elem->seq_name[0])
fprintf(file,"longname %s\n",this_elem->seq_name); fprintf(file, "longname %s\n",
this_elem->seq_name);
if (this_elem->id[0]) if (this_elem->id[0])
fprintf(file,"sequence-ID \"%s\"\n",this_elem->id); fprintf(file, "sequence-ID \"%s\"\n",
this_elem->id);
RemoveQuotes(this_elem->barcode); RemoveQuotes(this_elem->barcode);
RemoveQuotes(this_elem->contig); RemoveQuotes(this_elem->contig);
if (this_elem->barcode[0]) if (this_elem->barcode[0])
fprintf(file,"barcode \"%s\"\n",this_elem->barcode); fprintf(file, "barcode \"%s\"\n",
this_elem->barcode);
if (this_elem->membrane[0]) if (this_elem->membrane[0])
fprintf(file,"membrane \"%s\"\n",this_elem->membrane); fprintf(file, "membrane \"%s\"\n",
this_elem->membrane);
if (this_elem->contig[0]) if (this_elem->contig[0])
fprintf(file,"contig \"%s\"\n",this_elem->contig); fprintf(file, "contig \"%s\"\n",
this_elem->contig);
if (this_elem->description[0]) if (this_elem->description[0])
fprintf(file,"descrip \"%s\"\n",this_elem->description); fprintf(file, "descrip \"%s\"\n",
this_elem->description);
if (this_elem->authority[0]) if (this_elem->authority[0])
fprintf(file,"creator \"%s\"\n",this_elem->authority); fprintf(file, "creator \"%s\"\n",
this_elem->authority);
if (this_elem->groupid) if (this_elem->groupid)
fprintf(file, "group-ID %d\n", fprintf(file, "group-ID %d\n",
this_elem->groupid); this_elem->groupid);
if(this_elem->offset+aln->rel_offset && method!=SELECT_REGION) if (this_elem->offset + aln->rel_offset &&
fprintf(file,"offset %d\n",this_elem->offset+aln->rel_offset); method != SELECT_REGION)
if(method == SELECT_REGION) fprintf(file, "offset %d\n",
{ this_elem->offset + aln->rel_offset);
if (method == SELECT_REGION) {
/* /*
* If selecting a region, the offset should be moved to the first * If selecting a region, the offset should
* non-'0' space in the mask. *be moved to the first non-'0' space in the
*mask.
*/ */
for(k=this_elem->offset;k<aln->selection_mask_len && for (k = this_elem->offset;
aln->selection_mask[k] == '0';k++); k < aln->selection_mask_len &&
fprintf(file,"offset %d\n", aln->rel_offset+k); aln->selection_mask[k] == '0';
k++)
;
fprintf(file, "offset %d\n",
aln->rel_offset + k);
} }
if (this_elem->t_stamp.origin.mm != 0) if (this_elem->t_stamp.origin.mm != 0)
fprintf(file, fprintf(
"creation-date %2d/%2d/%2d %2d:%2d:%2d\n", file,
"creation-date %2d/%2d/%2d "
"%2d:%2d:%2d\n",
this_elem->t_stamp.origin.mm, this_elem->t_stamp.origin.mm,
this_elem->t_stamp.origin.dd, this_elem->t_stamp.origin.dd,
(this_elem->t_stamp.origin.yy)>1900? (this_elem->t_stamp.origin.yy) > 1900
(this_elem->t_stamp.origin.yy-1900): ? (this_elem->t_stamp.origin.yy - 1900)
(this_elem->t_stamp.origin.yy), : (this_elem->t_stamp.origin.yy),
this_elem->t_stamp.origin.hr, this_elem->t_stamp.origin.hr,
this_elem->t_stamp.origin.mn, this_elem->t_stamp.origin.mn,
this_elem->t_stamp.origin.sc); this_elem->t_stamp.origin.sc);
@ -513,82 +487,123 @@ int method,maskable;
(this_elem->attr & IS_SECONDARY)) (this_elem->attr & IS_SECONDARY))
fprintf(file, "strandedness 2\n"); fprintf(file, "strandedness 2\n");
if(this_elem->comments != NULL) if (this_elem->comments != NULL) {
{
StripSpecial(this_elem->comments); StripSpecial(this_elem->comments);
fprintf(file,"comments \"%s\"\n",this_elem->comments); fprintf(file, "comments \"%s\"\n",
this_elem->comments);
} }
if(this_elem->baggage != NULL) if (this_elem->baggage != NULL) {
{ if (this_elem
if(this_elem-> ->baggage[strlen(this_elem->baggage) -
baggage[strlen(this_elem->baggage)-1] == '\n') 1] == '\n')
fprintf(file, "%s", this_elem->baggage); fprintf(file, "%s", this_elem->baggage);
else else
fprintf(file,"%s\n",this_elem->baggage); fprintf(file, "%s\n",
this_elem->baggage);
} }
fprintf(file, "sequence \""); fprintf(file, "sequence \"");
if(this_elem->tmatrix) if (this_elem->tmatrix) {
{ if (mask == -1) {
if(mask == -1) for (k = this_elem->offset;
{ k < this_elem->seqlen +
for(k=this_elem->offset;k<this_elem->seqlen+this_elem->offset;k++) this_elem->offset;
{ k++) {
if (k % 60 == 0) if (k % 60 == 0)
putc('\n', file); putc('\n', file);
if(method == SELECT_REGION) if (method == SELECT_REGION) {
{ if (aln->selection_mask
if(aln->selection_mask[k] == '1') [k] == '1')
putc(this_elem->tmatrix[getelem(this_elem,k)], putc(
this_elem->tmatrix
[getelem(
this_elem,
k)],
file); file);
} }
else else
putc(this_elem->tmatrix[getelem(this_elem,k)], putc(this_elem->tmatrix
[getelem(
this_elem,
k)],
file); file);
} }
} }
else else {
{ for (i = 0, k = this_elem->offset;
for(i=0,k=this_elem->offset;k<this_elem->seqlen+this_elem->offset;k++) k < this_elem->seqlen +
if(aln->element[mask].seqlen+this_elem->offset>k) this_elem->offset;
if((char)getelem(&(aln->element[mask]),k) != '0' k++)
&& ((char)getelem(&(aln->element[mask]),k) != '-')) if (aln->element[mask].seqlen +
{ this_elem->offset >
k)
if ((char)getelem(
&(aln->element
[mask]),
k) != '0' &&
((char)getelem(
&(aln->element
[mask]),
k) != '-')) {
if (i % 60 == 0) if (i % 60 == 0)
putc('\n',file); putc(
putc(this_elem->tmatrix[getelem(this_elem,k)], '\n',
file);
putc(
this_elem->tmatrix
[getelem(
this_elem,
k)],
file); file);
i++; i++;
} }
} }
fprintf(file, "\"\n"); fprintf(file, "\"\n");
} }
else else {
{ if (mask == -1) {
if(mask == -1) for (k = this_elem->offset;
{ k < this_elem->seqlen +
for(k=this_elem->offset;k<this_elem->seqlen+this_elem->offset;k++) this_elem->offset;
{ k++) {
if (k % 60 == 0) if (k % 60 == 0)
putc('\n', file); putc('\n', file);
if(method == SELECT_REGION) if (method == SELECT_REGION) {
{ if (aln->selection_mask
if(aln->selection_mask[k] == '1') [k] == '1')
putc(getelem(this_elem,k),file); putc(
getelem(
this_elem,
k),
file);
} }
else else
putc(getelem(this_elem,k),file); putc(getelem(this_elem,
k),
file);
} }
} }
else else {
{ for (i = 0, k = this_elem->offset;
for(i=0,k=this_elem->offset;k<this_elem->seqlen+this_elem->offset;k++) k < this_elem->seqlen +
if(((aln->element[mask].seqlen)+(aln->element[mask]. this_elem->offset;
offset)) > k) k++)
if((char)getelem(&(aln->element[mask]),k) == '1') if (((aln->element[mask]
{ .seqlen) +
(aln->element[mask]
.offset)) > k)
if ((char)getelem(
&(aln->element
[mask]),
k) == '1') {
if (i % 60 == 0) if (i % 60 == 0)
putc('\n',file); putc(
putc(getelem(this_elem,k),file); '\n',
file);
putc(
getelem(
this_elem,
k),
file);
i++; i++;
} }
} }
@ -601,15 +616,12 @@ int method,maskable;
return; return;
} }
StripSpecial(string) char *string;
StripSpecial(string)
char *string;
{ {
register int i, j, len; register int i, j, len;
len = strlen(string); len = strlen(string);
for(j=0;j<len;j++) for (j = 0; j < len; j++) {
{
if (string[j] == '"') if (string[j] == '"')
string[j] = '`'; string[j] = '`';
else if (string[j] == '{') else if (string[j] == '{')
@ -620,35 +632,31 @@ char *string;
return; return;
} }
RemoveQuotes(string) RemoveQuotes(string) char *string;
char *string;
{ {
register int i, j, len; register int i, j, len;
len = strlen(string); len = strlen(string);
for (j = 0; j < len; j++) for (j = 0; j < len; j++)
if(string[j] == '"') if (string[j] == '"') string[j] = ' ';
string[j] = ' ';
for(j=0;string[j]==' ' && j<strlen(string);j++); for (j = 0; string[j] == ' ' && j < strlen(string); j++)
;
len = strlen(string); len = strlen(string);
for(i=0;i<len - j;i++) for (i = 0; i < len - j; i++) string[i] = string[i + j];
string[i] = string[i+j];
for(j=strlen(string)-1;j>=0 && (string[j]=='\n'||string[j]==' '); j--) for (j = strlen(string) - 1;
j >= 0 && (string[j] == '\n' || string[j] == ' '); j--)
string[j] = '\0'; string[j] = '\0';
return; return;
} }
/* /*
* Normalize seq (remove leading indels in the sequence; * Normalize seq (remove leading indels in the sequence;
*/ */
void SeqNorm(seq) void SeqNorm(seq) NA_Sequence *seq;
NA_Sequence *seq;
{ {
int len, j, shift_width, trailer; int len, j, shift_width, trailer;
char *sequence; char *sequence;
@ -660,18 +668,23 @@ NA_Sequence *seq;
if (seq->tmatrix) if (seq->tmatrix)
for (shift_width = 0; (shift_width < len) && for (shift_width = 0; (shift_width < len) &&
((sequence[shift_width]&15) == '\0'); shift_width++); ((sequence[shift_width] & 15) == '\0');
shift_width++)
;
else else
for(shift_width=0; (shift_width<len) && for (shift_width = 0;
(sequence[shift_width] == '-'); shift_width++); (shift_width < len) && (sequence[shift_width] == '-');
shift_width++)
;
for (j = 0; j < len - shift_width; j++) for (j = 0; j < len - shift_width; j++)
sequence[j] = sequence[j + shift_width]; sequence[j] = sequence[j + shift_width];
seq->seqlen -= shift_width; seq->seqlen -= shift_width;
seq->offset += shift_width; seq->offset += shift_width;
for(trailer=seq->seqlen-1;(sequence[trailer] =='-' || for (trailer = seq->seqlen - 1;
sequence[trailer] == '\0') && trailer>=0; (sequence[trailer] == '-' || sequence[trailer] == '\0') &&
trailer >= 0;
trailer--) trailer--)
sequence[trailer] = '\0'; sequence[trailer] = '\0';
seq->seqlen = trailer + 1; seq->seqlen = trailer + 1;
@ -692,8 +705,7 @@ char *uniqueID()
tp = (time_t *)Calloc(1, sizeof(time_t)); tp = (time_t *)Calloc(1, sizeof(time_t));
if(gethostname(hname, 10) == -1) if (gethostname(hname, 10) == -1) {
{
fprintf(stderr, "UniqueID(): Failed to get host name.\n"); fprintf(stderr, "UniqueID(): Failed to get host name.\n");
exit(1); exit(1);
} }
@ -709,82 +721,74 @@ char *uniqueID()
* OverWrite(), overwrite all non-default data from a sequence entry * OverWrite(), overwrite all non-default data from a sequence entry
* onto any entry with the same ID or short name. * onto any entry with the same ID or short name.
*/ */
OverWrite(this,aln) OverWrite(this, aln) NA_Sequence *this;
NA_Sequence *this;
NA_Alignment *aln; NA_Alignment *aln;
{ {
int j, indx = -1; int j, indx = -1;
NA_Sequence *that; NA_Sequence *that;
for(j=0;j<aln->numelements;j++) for (j = 0; j < aln->numelements; j++) {
{
if (Find2(this->id, aln->element[j].id) != -1) if (Find2(this->id, aln->element[j].id) != -1)
if(Find2(aln->element[j].id,this->id) != -1) if (Find2(aln->element[j].id, this->id) != -1) indx = j;
indx = j;
} }
if (indx == -1) if (indx == -1)
for(j=0;j<aln->numelements;j++) for (j = 0; j < aln->numelements; j++) {
{ if (Find2(this->short_name,
if(Find2(this->short_name,aln->element[j].short_name)!= -1) aln->element[j].short_name) != -1)
if(Find2(aln->element[j].short_name,this->short_name)!= -1) if (Find2(aln->element[j].short_name,
this->short_name) != -1)
indx = j; indx = j;
} }
if(indx != -1) if (indx != -1) {
{
that = &(aln->element[indx]); that = &(aln->element[indx]);
if(this->seq_name[0]) if (this->seq_name[0]) strcpy(that->seq_name, this->seq_name);
strcpy(that->seq_name,this->seq_name); if (this->barcode[0]) strcpy(that->barcode, this->barcode);
if(this->barcode[0]) if (this->contig[0]) strcpy(that->contig, this->contig);
strcpy(that->barcode,this->barcode); if (this->membrane[0]) strcpy(that->membrane, this->membrane);
if(this->contig[0])
strcpy(that->contig,this->contig);
if(this->membrane[0])
strcpy(that->membrane,this->membrane);
if (this->authority[0]) if (this->authority[0])
strcpy(that->authority, this->authority); strcpy(that->authority, this->authority);
if (this->short_name[0]) if (this->short_name[0])
strcpy(that->short_name, this->short_name); strcpy(that->short_name, this->short_name);
if (this->description[0]) if (this->description[0])
strcpy(that->description, this->description); strcpy(that->description, this->description);
if(this->sequence) if (this->sequence) {
{
cfree(that->sequence); cfree(that->sequence);
that->sequence = this->sequence; that->sequence = this->sequence;
that->seqlen = this->seqlen; that->seqlen = this->seqlen;
that->seqmaxlen = this->seqmaxlen; that->seqmaxlen = this->seqmaxlen;
} }
if(this->baggage) if (this->baggage) {
{
that->baggage_len += this->baggage_len; that->baggage_len += this->baggage_len;
that->baggage_maxlen += this->baggage_maxlen; that->baggage_maxlen += this->baggage_maxlen;
if (that->baggage) if (that->baggage)
that->baggage = that->baggage = Realloc(
Realloc(that->baggage,that->baggage_maxlen*sizeof(char)); that->baggage,
that->baggage_maxlen * sizeof(char));
else else
that->baggage = Calloc(that->baggage_maxlen,sizeof(char)); that->baggage =
strncat(that->baggage,this->baggage,that->baggage_maxlen); Calloc(that->baggage_maxlen, sizeof(char));
strncat(that->baggage, this->baggage,
that->baggage_maxlen);
} }
if(this->comments) if (this->comments) {
{
that->comments_len += this->comments_len; that->comments_len += this->comments_len;
that->comments_maxlen += this->comments_maxlen; that->comments_maxlen += this->comments_maxlen;
if (that->comments) if (that->comments)
that->comments = that->comments = Realloc(
Realloc(that->comments,that->comments_maxlen*sizeof(char)); that->comments,
that->comments_maxlen * sizeof(char));
else else
that->comments = Calloc(that->comments_maxlen,sizeof(char)); that->comments =
strncat(that->comments,this->comments,that->comments_maxlen); Calloc(that->comments_maxlen, sizeof(char));
strncat(that->comments, this->comments,
that->comments_maxlen);
} }
if(this->cmask) if (this->cmask) {
{
cfree(that->cmask); cfree(that->cmask);
that->cmask = this->cmask; that->cmask = this->cmask;
} }
if(this->offset != that->offset) if (this->offset != that->offset) that->offset = this->offset;
that->offset = this->offset; if (this->attr != 0) that->attr = this->attr;
if(this->attr != 0) if (this->groupid != 0) {
that->attr = this->attr;
if(this->groupid != 0)
{
that->groupid = this->groupid; that->groupid = this->groupid;
} }
that->groupb = NULL; that->groupb = NULL;

View file

@ -1,9 +1,10 @@
#include <stdio.h>
#include <malloc.h> #include <malloc.h>
#include <xview/xview.h> #include <stdio.h>
#include <xview/panel.h> #include <xview/panel.h>
#include "menudefs.h" #include <xview/xview.h>
#include "defines.h" #include "defines.h"
#include "menudefs.h"
/* /*
ParseMenus(): Read in the menu config file, and generate the internal ParseMenus(): Read in the menu config file, and generate the internal
@ -40,28 +41,24 @@ ParseMenu()
* First search the local directory, then the home directory. * First search the local directory, then the home directory.
*/ */
file = fopen(".GDEmenus", "r"); file = fopen(".GDEmenus", "r");
if(file == NULL) if (file == NULL) {
{
home = (char *)getenv("HOME"); home = (char *)getenv("HOME");
strcpy(temp, home); strcpy(temp, home);
strcat(temp, "/.GDEmenus"); strcat(temp, "/.GDEmenus");
file = fopen(temp, "r"); file = fopen(temp, "r");
if(file == NULL) if (file == NULL) {
{
home = (char *)getenv("GDE_HELP_DIR"); home = (char *)getenv("GDE_HELP_DIR");
if(home != NULL) if (home != NULL) {
{
strcpy(temp, home); strcpy(temp, home);
strcat(temp, "/.GDEmenus"); strcat(temp, "/.GDEmenus");
file = fopen(temp, "r"); file = fopen(temp, "r");
} }
if (file == NULL) if (file == NULL)
Error( Error(
".GDEmenus file not in the home, local, or $GDE_HELP_DIR directory"); ".GDEmenus file not in the home, local, or "
"$GDE_HELP_DIR directory");
} }
} }
/* /*
@ -69,31 +66,27 @@ ParseMenu()
* of the menu/menu-item hierarchy. * of the menu/menu-item hierarchy.
*/ */
for(;getline(file,Inline) != EOF;) for (; gde_getline(file, Inline) != EOF;) {
{
/* /*
* menu: chooses menu to use * menu: chooses menu to use
*/ */
if(Inline[0] == '#'); if (Inline[0] == '#')
else if(Find(Inline,"menu:")) ;
{ else if (Find(Inline, "menu:")) {
crop(Inline, head, temp); crop(Inline, head, temp);
curmenu = -1; curmenu = -1;
for (j = 0; j < num_menus; j++) for (j = 0; j < num_menus; j++)
if(Find(temp,menu[j].label)) if (Find(temp, menu[j].label)) curmenu = j;
curmenu=j;
/* /*
* If menu not found, make a new one * If menu not found, make a new one
*/ */
if(curmenu == -1) if (curmenu == -1) {
{
curmenu = num_menus++; curmenu = num_menus++;
thismenu = &menu[curmenu]; thismenu = &menu[curmenu];
thismenu->label = thismenu->label = (char *)calloc(
(char*)calloc(strlen(temp)+1,sizeof(char)); strlen(temp) + 1, sizeof(char));
if(thismenu->label == NULL) if (thismenu->label == NULL) Error("Calloc");
Error("Calloc");
(void)strcpy(thismenu->label, temp); (void)strcpy(thismenu->label, temp);
thismenu->numitems = 0; thismenu->numitems = 0;
} }
@ -101,29 +94,29 @@ ParseMenu()
/* /*
* item: chooses menu item to use * item: chooses menu item to use
*/ */
else if(Find(Inline,"item:")) else if (Find(Inline, "item:")) {
{
curarg = -1; curarg = -1;
curinput = -1; curinput = -1;
curoutput = -1; curoutput = -1;
crop(Inline, head, temp); crop(Inline, head, temp);
curitem = thismenu->numitems++; curitem = thismenu->numitems++;
/* /*
* Resize the item list for this menu (add one item); * Resize the item list for this menu (add one
*item);
*/ */
if (curitem == 0) if (curitem == 0)
resize = (char *)calloc(1, sizeof(GmenuItem)); resize = (char *)calloc(1, sizeof(GmenuItem));
else else
resize = realloc(thismenu->item, resize = realloc(
thismenu->item,
thismenu->numitems * sizeof(GmenuItem)); thismenu->numitems * sizeof(GmenuItem));
if(resize == NULL) if (resize == NULL) Error("Calloc");
Error ("Calloc");
thismenu->item = (GmenuItem *)resize; thismenu->item = (GmenuItem *)resize;
thisitem = &(thismenu->item[curitem]); thisitem = &(thismenu->item[curitem]);
thisitem->label = (char*)calloc(strlen(temp)+1, thisitem->label =
sizeof(char)); (char *)calloc(strlen(temp) + 1, sizeof(char));
thisitem->meta = '\0'; thisitem->meta = '\0';
thisitem->numinputs = 0; thisitem->numinputs = 0;
thisitem->numoutputs = 0; thisitem->numoutputs = 0;
@ -135,69 +128,61 @@ ParseMenu()
* Create new item * Create new item
*/ */
if(thisitem->label == NULL) if (thisitem->label == NULL) Error("Calloc");
Error("Calloc");
(void)strcpy(thisitem->label, temp); (void)strcpy(thisitem->label, temp);
} }
/* /*
* itemmethod: generic command line generated by this item * itemmethod: generic command line generated by this item
*/ */
else if(Find(Inline,"itemmethod:")) else if (Find(Inline, "itemmethod:")) {
{
crop(Inline, head, temp); crop(Inline, head, temp);
thisitem->method = thisitem->method =
(char *)calloc(strlen(temp) + 1, sizeof(char)); (char *)calloc(strlen(temp) + 1, sizeof(char));
if(thisitem->method == NULL) if (thisitem->method == NULL) Error("Calloc");
Error("Calloc");
(void)strcpy(thisitem->method, temp); (void)strcpy(thisitem->method, temp);
} }
/* /*
* Help file * Help file
*/ */
else if(Find(Inline,"itemhelp:")) else if (Find(Inline, "itemhelp:")) {
{
crop(Inline, head, temp); crop(Inline, head, temp);
thisitem->help = thisitem->help =
(char *)calloc(strlen(temp) + 1, sizeof(char)); (char *)calloc(strlen(temp) + 1, sizeof(char));
if(thisitem->method == NULL) if (thisitem->method == NULL) Error("Calloc");
Error("Calloc");
(void)strcpy(thisitem->help, temp); (void)strcpy(thisitem->help, temp);
} }
/* /*
* Meta key equiv * Meta key equiv
*/ */
else if(Find(Inline,"itemmeta:")) else if (Find(Inline, "itemmeta:")) {
{
crop(Inline, head, temp); crop(Inline, head, temp);
thisitem->meta = temp[0]; thisitem->meta = temp[0];
} }
/* /*
* arg: defines the symbol for a command line arguement. * arg: defines the symbol for a command line arguement.
* this is used for substitution into the itemmethod * this is used for substitution into the
* definition. *itemmethod definition.
*/ */
else if(Find(Inline,"arg:")) else if (Find(Inline, "arg:")) {
{
crop(Inline, head, temp); crop(Inline, head, temp);
curarg = thisitem->numargs++; curarg = thisitem->numargs++;
if (curarg == 0) if (curarg == 0)
resize = (char*)calloc(1,sizeof(GmenuItemArg)); resize =
(char *)calloc(1, sizeof(GmenuItemArg));
else else
resize = realloc(thisitem->arg, resize = realloc(
thisitem->arg,
thisitem->numargs * sizeof(GmenuItemArg)); thisitem->numargs * sizeof(GmenuItemArg));
if (resize == NULL) Error("arg: Realloc");
if(resize == NULL)
Error("arg: Realloc");
(thisitem->arg) = (GmenuItemArg *)resize; (thisitem->arg) = (GmenuItemArg *)resize;
thisarg = &(thisitem->arg[curarg]); thisarg = &(thisitem->arg[curarg]);
thisarg->symbol = (char*)calloc(strlen(temp)+1, thisarg->symbol =
sizeof(char)); (char *)calloc(strlen(temp) + 1, sizeof(char));
if(thisarg->symbol == NULL) if (thisarg->symbol == NULL) Error("Calloc");
Error("Calloc");
(void)strcpy(thisarg->symbol, temp); (void)strcpy(thisarg->symbol, temp);
thisarg->optional = FALSE; thisarg->optional = FALSE;
thisarg->type = 0; thisarg->type = 0;
@ -209,18 +194,16 @@ ParseMenu()
thisarg->value = 0; thisarg->value = 0;
} }
/* /*
* argtype: Defines the type of argument (menu,chooser, text, slider) * argtype: Defines the type of argument (menu,chooser,
*text, slider)
*/ */
else if(Find(Inline,"argtype:")) else if (Find(Inline, "argtype:")) {
{
crop(Inline, head, temp); crop(Inline, head, temp);
if(strcmp(temp,"text")==0) if (strcmp(temp, "text") == 0) {
{
thisarg->type = TEXTFIELD; thisarg->type = TEXTFIELD;
thisarg->textvalue = thisarg->textvalue =
(char *)calloc(GBUFSIZ, sizeof(char)); (char *)calloc(GBUFSIZ, sizeof(char));
if(thisarg->textvalue == NULL) if (thisarg->textvalue == NULL) Error("Calloc");
Error("Calloc");
} }
else if (strcmp(temp, "choice_list") == 0) else if (strcmp(temp, "choice_list") == 0)
thisarg->type = CHOICE_LIST; thisarg->type = CHOICE_LIST;
@ -231,29 +214,28 @@ ParseMenu()
else if (strcmp(temp, "slider") == 0) else if (strcmp(temp, "slider") == 0)
thisarg->type = SLIDER; thisarg->type = SLIDER;
else else
Error(sprintf(head,"Unknown argtype %s",temp)); Error(
sprintf(head, "Unknown argtype %s", temp));
} }
/* /*
* argtext: The default text value of the symbol. * argtext: The default text value of the symbol.
* $argument is replaced by this value if it is not * $argument is replaced by this value if it is not
* changed in the dialog box by the user. * changed in the dialog box by the user.
*/ */
else if(Find(Inline,"argtext:")) else if (Find(Inline, "argtext:")) {
{
crop(Inline, head, temp); crop(Inline, head, temp);
(void)strcpy(thisarg->textvalue, temp); (void)strcpy(thisarg->textvalue, temp);
} }
/* /*
* arglabel: Text label displayed in the dialog box for * arglabel: Text label displayed in the dialog box for
* this argument. It should be a discriptive label. * this argument. It should be a discriptive
*label.
*/ */
else if(Find(Inline,"arglabel:")) else if (Find(Inline, "arglabel:")) {
{
crop(Inline, head, temp); crop(Inline, head, temp);
thisarg->label=(char*)calloc(strlen(temp)+1, thisarg->label =
sizeof(char)); (char *)calloc(strlen(temp) + 1, sizeof(char));
if(thisarg->label == NULL) if (thisarg->label == NULL) Error("Calloc");
Error("Calloc");
(void)strcpy(thisarg->label, temp); (void)strcpy(thisarg->label, temp);
} }
/* /*
@ -261,22 +243,22 @@ ParseMenu()
* *
* argchoice:Displayed value:Method * argchoice:Displayed value:Method
* *
* Where "Displayed value" is the label displayed in the dialog box * Where "Displayed value" is the label displayed in the
* and "Method" is the value passed back on the command line. *dialog box and "Method" is the value passed back on the
*command line.
*/ */
else if(Find(Inline,"argchoice:")) else if (Find(Inline, "argchoice:")) {
{
crop(Inline, head, temp); crop(Inline, head, temp);
crop(temp, head, tail); crop(temp, head, tail);
curchoice = thisarg->numchoices++; curchoice = thisarg->numchoices++;
if (curchoice == 0) if (curchoice == 0)
resize = (char *)calloc(1, sizeof(GargChoice)); resize = (char *)calloc(1, sizeof(GargChoice));
else else
resize = realloc(thisarg->choice, resize = realloc(
thisarg->choice,
thisarg->numchoices * sizeof(GargChoice)); thisarg->numchoices * sizeof(GargChoice));
if(resize == NULL) if (resize == NULL) Error("argchoice: Realloc");
Error("argchoice: Realloc");
thisarg->choice = (GargChoice *)resize; thisarg->choice = (GargChoice *)resize;
(thisarg->choice[curchoice].label) = NULL; (thisarg->choice[curchoice].label) = NULL;
@ -298,36 +280,31 @@ ParseMenu()
/* /*
* argmin: Minimum value for a slider * argmin: Minimum value for a slider
*/ */
else if(Find(Inline,"argmin:")) else if (Find(Inline, "argmin:")) {
{
crop(Inline, head, temp); crop(Inline, head, temp);
(void)sscanf(temp, "%d", &(thisarg->min)); (void)sscanf(temp, "%d", &(thisarg->min));
} }
/* /*
* argmax: Maximum value for a slider * argmax: Maximum value for a slider
*/ */
else if(Find(Inline,"argmax:")) else if (Find(Inline, "argmax:")) {
{
crop(Inline, head, temp); crop(Inline, head, temp);
(void)sscanf(temp, "%d", &(thisarg->max)); (void)sscanf(temp, "%d", &(thisarg->max));
} }
/* /*
* argmethod: Command line flag associated with this argument. * argmethod: Command line flag associated with this
* Replaces argument in itemmethod description. *argument. Replaces argument in itemmethod description.
*/ */
else if(Find(Inline,"argmethod:")) else if (Find(Inline, "argmethod:")) {
{
crop(Inline, head, temp); crop(Inline, head, temp);
thisarg->method = (char *)calloc(GBUFSIZ, strlen(temp)); thisarg->method = (char *)calloc(GBUFSIZ, strlen(temp));
if(thisarg->method == NULL) if (thisarg->method == NULL) Error("Calloc");
Error("Calloc");
(void)strcpy(thisarg->method, tail); (void)strcpy(thisarg->method, tail);
} }
/* /*
* argvalue: default value for a slider * argvalue: default value for a slider
*/ */
else if(Find(Inline,"argvalue:")) else if (Find(Inline, "argvalue:")) {
{
crop(Inline, head, temp); crop(Inline, head, temp);
if (thisarg->type == TEXT) if (thisarg->type == TEXT)
strcpy(thisarg->textvalue, temp); strcpy(thisarg->textvalue, temp);
@ -335,25 +312,25 @@ ParseMenu()
(void)sscanf(temp, "%d", &(thisarg->value)); (void)sscanf(temp, "%d", &(thisarg->value));
} }
/* /*
* argoptional: Flag specifying that an arguement is optional * argoptional: Flag specifying that an arguement is
*optional
*/ */
else if (Find(Inline, "argoptional:")) else if (Find(Inline, "argoptional:"))
thisarg->optional = TRUE; thisarg->optional = TRUE;
/* /*
* in: Input file description * in: Input file description
*/ */
else if(Find(Inline,"in:")) else if (Find(Inline, "in:")) {
{
crop(Inline, head, temp); crop(Inline, head, temp);
curinput = (thisitem->numinputs)++; curinput = (thisitem->numinputs)++;
if (curinput == 0) if (curinput == 0)
resize = (char *)calloc(1, sizeof(GfileFormat)); resize = (char *)calloc(1, sizeof(GfileFormat));
else else
resize = realloc(thisitem->input, resize = realloc(thisitem->input,
(thisitem->numinputs)*sizeof(GfileFormat)); (thisitem->numinputs) *
sizeof(GfileFormat));
if(resize == NULL) if (resize == NULL) Error("in: Realloc");
Error("in: Realloc");
thisitem->input = (GfileFormat *)resize; thisitem->input = (GfileFormat *)resize;
thisinput = &(thisitem->input)[curinput]; thisinput = &(thisitem->input)[curinput];
thisinput->save = FALSE; thisinput->save = FALSE;
@ -369,18 +346,17 @@ ParseMenu()
* out: Output file description * out: Output file description
*/ */
else if(Find(Inline,"out:")) else if (Find(Inline, "out:")) {
{
crop(Inline, head, temp); crop(Inline, head, temp);
curoutput = (thisitem->numoutputs)++; curoutput = (thisitem->numoutputs)++;
if (curoutput == 0) if (curoutput == 0)
resize = (char *)calloc(1, sizeof(GfileFormat)); resize = (char *)calloc(1, sizeof(GfileFormat));
else else
resize = realloc(thisitem->output, resize = realloc(thisitem->output,
(thisitem->numoutputs)*sizeof(GfileFormat)); (thisitem->numoutputs) *
sizeof(GfileFormat));
if(resize == NULL) if (resize == NULL) Error("out: Realloc");
Error("out: Realloc");
thisitem->output = (GfileFormat *)resize; thisitem->output = (GfileFormat *)resize;
thisoutput = &(thisitem->output)[curoutput]; thisoutput = &(thisitem->output)[curoutput];
thisitem->output = (GfileFormat *)resize; thisitem->output = (GfileFormat *)resize;
@ -391,10 +367,8 @@ ParseMenu()
thisoutput->symbol = String(temp); thisoutput->symbol = String(temp);
thisoutput->name = NULL; thisoutput->name = NULL;
} }
else if(Find(Inline,"informat:")) else if (Find(Inline, "informat:")) {
{ if (thisinput == NULL) Error("Problem with .GDEmenus");
if(thisinput == NULL)
Error("Problem with .GDEmenus");
crop(Inline, head, tail); crop(Inline, head, tail);
if (Find(tail, "genbank")) if (Find(tail, "genbank"))
thisinput->format = GENBANK; thisinput->format = GENBANK;
@ -408,19 +382,17 @@ ParseMenu()
thisinput->format = NA_FLAT; thisinput->format = NA_FLAT;
else if (Find(tail, "status")) else if (Find(tail, "status"))
thisinput->format = STATUS_FILE; thisinput->format = STATUS_FILE;
else fprintf(stderr,"Warning, unknown file format %s\n" else
,tail); fprintf(stderr,
"Warning, unknown file format %s\n",
tail);
} }
else if(Find(Inline,"insave:")) else if (Find(Inline, "insave:")) {
{ if (thisinput == NULL) Error("Problem with .GDEmenus");
if(thisinput == NULL)
Error("Problem with .GDEmenus");
thisinput->save = TRUE; thisinput->save = TRUE;
} }
else if(Find(Inline,"inselect:")) else if (Find(Inline, "inselect:")) {
{ if (thisinput == NULL) Error("Problem with .GDEmenus");
if(thisinput == NULL)
Error("Problem with .GDEmenus");
crop(Inline, head, tail); crop(Inline, head, tail);
if (Find(tail, "one")) if (Find(tail, "one"))
thisinput->select = SELECT_ONE; thisinput->select = SELECT_ONE;
@ -429,16 +401,12 @@ ParseMenu()
else if (Find(tail, "all")) else if (Find(tail, "all"))
thisinput->select = ALL; thisinput->select = ALL;
} }
else if(Find(Inline,"inmask:")) else if (Find(Inline, "inmask:")) {
{ if (thisinput == NULL) Error("Problem with .GDEmenus");
if(thisinput == NULL)
Error("Problem with .GDEmenus");
thisinput->maskable = TRUE; thisinput->maskable = TRUE;
} }
else if(Find(Inline,"outformat:")) else if (Find(Inline, "outformat:")) {
{ if (thisoutput == NULL) Error("Problem with .GDEmenus");
if(thisoutput == NULL)
Error("Problem with .GDEmenus");
crop(Inline, head, tail); crop(Inline, head, tail);
if (Find(tail, "genbank")) if (Find(tail, "genbank"))
thisoutput->format = GENBANK; thisoutput->format = GENBANK;
@ -452,50 +420,41 @@ ParseMenu()
thisoutput->format = STATUS_FILE; thisoutput->format = STATUS_FILE;
else if (Find(tail, "colormask")) else if (Find(tail, "colormask"))
thisoutput->format = COLORMASK; thisoutput->format = COLORMASK;
else fprintf(stderr,"Warning, unknown file format %s\n" else
,tail); fprintf(stderr,
"Warning, unknown file format %s\n",
tail);
} }
else if(Find(Inline,"outsave:")) else if (Find(Inline, "outsave:")) {
{ if (thisoutput == NULL) Error("Problem with .GDEmenus");
if(thisoutput == NULL)
Error("Problem with .GDEmenus");
thisoutput->save = TRUE; thisoutput->save = TRUE;
} }
else if(Find(Inline,"outoverwrite:")) else if (Find(Inline, "outoverwrite:")) {
{ if (thisoutput == NULL) Error("Problem with .GDEmenus");
if(thisoutput == NULL)
Error("Problem with .GDEmenus");
thisoutput->overwrite = TRUE; thisoutput->overwrite = TRUE;
} }
} }
return; return;
} }
/* /*
Find(): Search the target string for the given key Find(): Search the target string for the given key
*/ */
Find(target,key) Find(target, key) char *key, *target;
char *key,*target;
{ {
int i, j, len1, dif, flag = FALSE; int i, j, len1, dif, flag = FALSE;
dif = (strlen(target)) - (len1 = strlen(key)) + 1; dif = (strlen(target)) - (len1 = strlen(key)) + 1;
if (len1 > 0) if (len1 > 0)
for(j=0;j<dif && flag == FALSE;j++) for (j = 0; j < dif && flag == FALSE; j++) {
{
flag = TRUE; flag = TRUE;
for (i = 0; i < len1 && flag; i++) for (i = 0; i < len1 && flag; i++)
flag = (key[i] == target[i + j]) ? TRUE : FALSE; flag = (key[i] == target[i + j]) ? TRUE : FALSE;
} }
return (flag); return (flag);
} }
Find2(target, key) char *key, *target;
Find2(target,key)
char *key,*target;
/* /*
* Like find, but returns the index of the leftmost * Like find, but returns the index of the leftmost
* occurence, and -1 if not found. * occurence, and -1 if not found.
@ -505,26 +464,21 @@ char *key,*target;
dif = (strlen(target)) - (len1 = strlen(key)) + 1; dif = (strlen(target)) - (len1 = strlen(key)) + 1;
if (len1 > 0) if (len1 > 0)
for(j=0;j<dif && flag == FALSE;j++) for (j = 0; j < dif && flag == FALSE; j++) {
{
flag = TRUE; flag = TRUE;
for (i = 0; i < len1 && flag; i++) for (i = 0; i < len1 && flag; i++)
flag = (key[i] == target[i + j]) ? TRUE : FALSE; flag = (key[i] == target[i + j]) ? TRUE : FALSE;
} }
return (flag ? j - 1 : -1); return (flag ? j - 1 : -1);
} }
Error(msg) char *msg;
Error(msg)
char *msg;
{ {
(void)fprintf(stderr, "%s\n", msg); (void)fprintf(stderr, "%s\n", msg);
exit(1); exit(1);
} }
int gde_getline(file, string)
int getline(file,string)
FILE *file; FILE *file;
char string[]; char string[];
{ {
@ -533,8 +487,10 @@ char string[];
for (i = 0; ((c = getc(file)) != '\n') && (c != EOF); i++) for (i = 0; ((c = getc(file)) != '\n') && (c != EOF); i++)
string[i] = c; string[i] = c;
string[i] = '\0'; string[i] = '\0';
if (i==0 && c==EOF) return (EOF); if (i == 0 && c == EOF)
else return (0); return (EOF);
else
return (0);
} }
/* /*
@ -543,12 +499,11 @@ Crop():
into: "this" and "that[:the_other]" into: "this" and "that[:the_other]"
*/ */
crop(input,head,tail) crop(input, head, tail) char input[], head[], tail[];
char input[],head[],tail[];
{ {
/* /*
* Crop needs to be fixed so that whitespace is compressed off the end * Crop needs to be fixed so that whitespace is compressed off the
* of tail *end of tail
*/ */
int offset, end, i, j, length; int offset, end, i, j, length;
@ -556,11 +511,12 @@ char input[],head[],tail[];
for (offset = 0; offset < length && input[offset] != ':'; offset++) for (offset = 0; offset < length && input[offset] != ':'; offset++)
head[offset] = input[offset]; head[offset] = input[offset];
head[offset++] = '\0'; head[offset++] = '\0';
for(;offset<length && input[offset] == ' ';offset++); for (; offset < length && input[offset] == ' '; offset++)
for(end=length-1;input[end] ==' ' && end>offset;end--); ;
for (end = length - 1; input[end] == ' ' && end > offset; end--)
;
for(j=0,i=offset;i<=end;i++,j++) for (j = 0, i = offset; i <= end; i++, j++) tail[j] = input[i];
tail[j]=input[i];
tail[j] = '\0'; tail[j] = '\0';
return; return;
} }