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

View file

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

View file

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