00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifdef HAVE_CONFIG_H
00022 #include "config.h"
00023 #endif
00024
00025 #include <stdlib.h>
00026 #include <string.h>
00027 #include <assert.h>
00028
00029 #include "libdefs.h"
00030 #include "error.h"
00031 #include "fileutils.h"
00032 #include "arrays.h"
00033 #include "alphabet.h"
00034 #include "sequences.h"
00035 #include "suffixarray.h"
00036 #include "createfiles.h"
00037 #include "verify.h"
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055 static int make_new_file(fid_Mappedfile *file, fid_Filenamebuffer *fnamebuf,
00056 const char *fileext, fid_Error *error)
00057 {
00058 memcpy(fnamebuf->bufptr,fileext,(size_t)4);
00059 return fid_file_new(file,fnamebuf->buffer,error);
00060 }
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082 int fid_create_online_files(fid_Sequences *seqs, const fid_Alphabet *alpha,
00083 const char *basefilename, fid_Tablerequest tables,
00084 fid_Uintsize uisize, fid_Error *error)
00085 {
00086 int retcode=0;
00087 fid_Filenamebuffer fnamebuf;
00088
00089 assert(seqs != NULL);
00090 assert(alpha != NULL);
00091 assert(basefilename != NULL);
00092 assert(tables != fid_TABLE_NONE);
00093
00094 VERIFY_ONLINE_REQUEST(tables,error);
00095
00096 if(fid_filenamebuffer_init(&fnamebuf,basefilename,error) == -1)
00097 {
00098 return -1;
00099 }
00100
00101 fid_sequences_init(seqs,uisize,alpha);
00102
00103 if((tables&fid_TABLE_TIS) != 0)
00104 {
00105 if((retcode=make_new_file(&seqs->tisfile,&fnamebuf,"tis",error)) == 0)
00106 {
00107 retcode=make_new_file(&seqs->sspfile,&fnamebuf,"ssp",error);
00108 }
00109 }
00110
00111 if(retcode == 0 && (tables&fid_TABLE_OIS) != 0)
00112 {
00113 if((retcode=make_new_file(&seqs->oisfile,&fnamebuf,"ois",error)) == 0 &&
00114 seqs->sspfile.content == NULL)
00115 {
00116 retcode=make_new_file(&seqs->sspfile,&fnamebuf,"ssp",error);
00117 }
00118 }
00119
00120 if(retcode == 0 && (tables&fid_TABLE_DES) != 0)
00121 {
00122 if((retcode=make_new_file(&seqs->desfile,&fnamebuf,"des",error)) == 0)
00123 {
00124 retcode=make_new_file(&seqs->sdsfile,&fnamebuf,"sds",error);
00125 }
00126 }
00127
00128 if(retcode != 0)
00129 {
00130 fid_file_cleanup(&seqs->tisfile);
00131 fid_file_cleanup(&seqs->oisfile);
00132 fid_file_cleanup(&seqs->sspfile);
00133 fid_file_cleanup(&seqs->desfile);
00134 fid_file_cleanup(&seqs->sdsfile);
00135 }
00136
00137 fid_filenamebuffer_free(&fnamebuf);
00138
00139 return retcode;
00140 }
00141
00142