Skip to content

Commit 1639f35

Browse files
committed
Handle .1ano file in GIXrm/cp/mv
1 parent 42fd339 commit 1639f35

3 files changed

Lines changed: 101 additions & 15 deletions

File tree

GIXrm.c

Lines changed: 38 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
#include "gene_core.h"
2020

21-
static char *Usage = "[-vifg] <source:path>[.1gdb|.gix] ... ";
21+
static char *Usage = "[-vifg] <source:path>[.1gdb|.gix|.1ano] ... ";
2222

2323
int main(int argc, char *argv[])
2424
{ int VERBOSE;
@@ -63,7 +63,7 @@ int main(int argc, char *argv[])
6363
// Determine source and target root names, paths, and extensions
6464

6565
{ char *PATH, *ROOT, *GEXTN;
66-
int HAS_GDB, HAS_GIX;
66+
int HAS_GDB, HAS_GIX, HAS_ANO;
6767
struct stat status;
6868
char *p, *com;
6969
FILE *input;
@@ -75,7 +75,7 @@ int main(int argc, char *argv[])
7575
com = "rm";
7676

7777
for (c = 1; c < argc; c++)
78-
{ HAS_GDB = HAS_GIX = 0;
78+
{ HAS_GDB = HAS_GIX = HAS_ANO = 0;
7979

8080
PATH = argv[c];
8181
p = rindex(PATH,'/');
@@ -114,6 +114,16 @@ int main(int argc, char *argv[])
114114
}
115115
}
116116

117+
input = fopen(Catenate(PATH,"/",ROOT,".1ano"),"r");
118+
if (input != NULL)
119+
{ fclose(input);
120+
HAS_ANO = 1;
121+
}
122+
else if (strcmp(ROOT+(strlen(ROOT)-5),".1ano") == 0)
123+
{ HAS_ANO = 1;
124+
ROOT[strlen(ROOT)-5] = '\0';
125+
}
126+
117127
input = fopen(Catenate(PATH,"/",ROOT,".gix"),"r");
118128
if (input != NULL)
119129
{ fclose(input);
@@ -126,9 +136,9 @@ int main(int argc, char *argv[])
126136

127137
command = Malloc(4*(strlen(PATH)+strlen(ROOT))+100,"Allocating command buffer");
128138

129-
if (HAS_GIX + HAS_GDB * GDB_TOO == 0)
139+
if (HAS_GIX + HAS_GDB * GDB_TOO + HAS_ANO * GDB_TOO == 0)
130140
{ if (GDB_TOO)
131-
fprintf(stderr," Warning: there is no GDB or GIX with root %s/%s\n",PATH,ROOT);
141+
fprintf(stderr," Warning: there is no GDB, GIX, or ANO with root %s/%s\n",PATH,ROOT);
132142
else
133143
fprintf(stderr," Warning: there is no GIX with root %s/%s\n",PATH,ROOT);
134144
}
@@ -185,6 +195,29 @@ int main(int argc, char *argv[])
185195
}
186196
}
187197

198+
if (HAS_ANO && GDB_TOO)
199+
{ yes = 1;
200+
if (ASK)
201+
{ printf("Remove %s/%s.1ano? ",PATH,ROOT);
202+
fflush(stdout);
203+
yes = 0;
204+
while ((a = getc(stdin)) != '\n')
205+
if (a == 'y' || a == 'Y')
206+
yes = 1;
207+
else if (a == 'n' || a == 'N')
208+
yes = 0;
209+
fflush(stdout);
210+
}
211+
if (yes)
212+
{ if (VERBOSE)
213+
{ fprintf(stderr," Removing %s/%s.1ano\n",PATH,ROOT);
214+
fflush(stderr);
215+
}
216+
sprintf(command,"%s %s/%s.1ano",com,PATH,ROOT);
217+
if (system(command) != 0) goto sys_error;
218+
}
219+
}
220+
188221
free(command);
189222
}
190223
}

GIXxfer.c

Lines changed: 59 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@
1515

1616
#include "gene_core.h"
1717
#include "GDB.h"
18+
#include "ANO.h"
1819

19-
static char *Usage = "[-vinfx] <source:path>[.1gdb|.gix] <target:path>[.1gdb|.gix]";
20+
static char *Usage = "[-vinfx] <source:path>[.1gdb|.gix|.1ano] <target:path>[.1gdb|.gix|.1ano]";
2021

2122
int main(int argc, char *argv[])
2223
{ int VERBOSE;
@@ -78,8 +79,9 @@ int main(int argc, char *argv[])
7879

7980
{ char *SPATH, *SROOT, *SEXTN;
8081
char *TPATH, *TROOT, *TEXTN;
81-
int HAS_GDB, HAS_GIX;
82+
int HAS_GDB, HAS_GIX, HAS_ANO;
8283
GDB _gdb, *gdb = &_gdb;
84+
ANO _ano, *ano = &_ano;
8385
struct stat status;
8486
char com[10];
8587
int a, yes;
@@ -91,7 +93,7 @@ int main(int argc, char *argv[])
9193
else
9294
sprintf(com,"mv");
9395

94-
HAS_GDB = HAS_GIX = 0;
96+
HAS_GDB = HAS_GIX = HAS_ANO = 0;
9597

9698
SPATH = argv[1];
9799
p = rindex(SPATH,'/');
@@ -140,6 +142,16 @@ int main(int argc, char *argv[])
140142
SROOT[strlen(SROOT)-4] = '\0';
141143
}
142144

145+
input = fopen(Catenate(SPATH,"/",SROOT,".1ano"),"r");
146+
if (input != NULL)
147+
{ fclose(input);
148+
HAS_ANO = 1;
149+
}
150+
else if (strcmp(SROOT+(strlen(SROOT)-5),".1ano") == 0)
151+
{ HAS_ANO = 1;
152+
SROOT[strlen(SROOT)-5] = '\0';
153+
}
154+
143155
TEXTN = ".1gdb";
144156
TPATH = argv[2];
145157
if (stat(TPATH,&status) == 0 && (status.st_mode & S_IFMT) == S_IFDIR)
@@ -168,8 +180,8 @@ int main(int argc, char *argv[])
168180
command = Malloc(strlen(SPATH)+strlen(SROOT)+strlen(TPATH)+strlen(TROOT)+100,
169181
"Allocating command buffer");
170182

171-
if (HAS_GIX + HAS_GDB == 0)
172-
fprintf(stderr," There is no GDB or GIX with root %s/%s\n",SPATH,SROOT);
183+
if (HAS_GIX + HAS_GDB + HAS_ANO == 0)
184+
fprintf(stderr," There is no GDB, GIX, or ANO with root %s/%s\n",SPATH,SROOT);
173185

174186
if (HAS_GIX)
175187
{ yes = 1;
@@ -255,7 +267,48 @@ int main(int argc, char *argv[])
255267
if (system(command) != 0) goto sys_error;
256268

257269
Write_GDB(gdb,Catenate(TPATH,"/",TROOT,TEXTN));
258-
Close_GDB(gdb);
270+
271+
if (HAS_ANO)
272+
{ yes = 1;
273+
if (ASK)
274+
{ yes = 0;
275+
#ifdef MOVE
276+
printf("Move %s/%s.1ano? ",SPATH,SROOT);
277+
#else
278+
printf("Copy %s/%s.1ano? ",SPATH,SROOT);
279+
#endif
280+
fflush(stdout);
281+
while ((a = getc(stdin)) != '\n')
282+
if (a == 'y' || a == 'Y')
283+
yes = 1;
284+
else if (a == 'n' || a == 'N')
285+
yes = 0;
286+
fflush(stdout);
287+
}
288+
if (yes)
289+
{ if (!NO_OVER || stat(Catenate(TPATH,"/",TROOT,".1ano"),&status) != 0)
290+
{ if (VERBOSE)
291+
#ifdef MOVE
292+
{ fprintf(stderr," Moving %s/%s.1ano to %s/%s.1ano\n",
293+
SPATH,SROOT,TPATH,TROOT);
294+
#else
295+
{ fprintf(stderr," Copying %s/%s.1ano to %s/%s.1ano\n",
296+
SPATH,SROOT,TPATH,TROOT);
297+
#endif
298+
fflush(stderr);
299+
}
300+
Read_ANO(ano,Catenate(SPATH,"/",SROOT,".1ano"), gdb);
301+
#ifdef MOVE
302+
sprintf(command,"rm %s/%s.1ano",SPATH,SROOT);
303+
if (system(command) != 0) goto sys_error;
304+
#endif
305+
306+
Write_ANO(ano,Catenate(TPATH,"/",TROOT,".1ano"));
307+
Free_ANO(ano);
308+
}
309+
}
310+
}
311+
Close_GDB(gdb);
259312
}
260313
}
261314
}

Makefile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,11 @@ GIXshow: GIXshow.c libfastk.c libfastk.h gene_core.c gene_core.h
3535
GIXrm: GIXrm.c gene_core.c gene_core.h
3636
$(CC) $(CFLAGS) -o GIXrm GIXrm.c gene_core.c -lm
3737

38-
GIXmv: GIXxfer.c GDB.c GDB.h gene_core.c ONElib.c ONElib.h gene_core.h
39-
$(CC) $(CFLAGS) -DMOVE -o GIXmv GIXxfer.c GDB.c ONElib.c gene_core.c -lm -lz
38+
GIXmv: GIXxfer.c GDB.c GDB.h ANO.c ANO.h gene_core.c ONElib.c ONElib.h gene_core.h
39+
$(CC) $(CFLAGS) -DMOVE -o GIXmv GIXxfer.c GDB.c ANO.c ONElib.c gene_core.c -lm -lz
4040

41-
GIXcp: GIXxfer.c GDB.c GDB.h ONElib.c ONElib.h gene_core.c gene_core.h
42-
$(CC) $(CFLAGS) -o GIXcp GIXxfer.c GDB.c ONElib.c gene_core.c -lm -lz
41+
GIXcp: GIXxfer.c GDB.c GDB.h ANO.c ANO.h ONElib.c ONElib.h gene_core.c gene_core.h
42+
$(CC) $(CFLAGS) -o GIXcp GIXxfer.c GDB.c ANO.c ONElib.c gene_core.c -lm -lz
4343

4444
FastGA: FastGA.c libfastk.c libfastk.h GDB.c GDB.h RSDsort.c align.c align.h alncode.c alncode.h ONElib.c ONElib.h
4545
$(CC) $(CFLAGS) -o FastGA FastGA.c RSDsort.c libfastk.c align.c GDB.c alncode.c gene_core.c ONElib.c -lpthread -lm -lz

0 commit comments

Comments
 (0)