00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035 static int sanity_checks(const fid_Suffixarray *esa,
00036 const fid_Projectfile *project,
00037 fid_Tablerequest tables, fid_Error *error)
00038 {
00039 int retcode=0;
00040
00041 if((tables&fid_TABLE_TIS) != 0)
00042 {
00043 if(esa->sequences.tisfile.content != NULL &&
00044 esa->sequences.tisfile.occupied != esa->sequences.total_length.VU)
00045 {
00046 fid_error_throw(error,"Size of \"%s.tis\" (%lu) does not "
00047 "match size stored in project file (" UINTFMT ").",
00048 project->prjbasename,
00049 (unsigned long)esa->sequences.tisfile.occupied,
00050 esa->sequences.total_length.VU);
00051 retcode=-1;
00052 }
00053 }
00054
00055 if((tables&fid_TABLE_OIS) != 0)
00056 {
00057 if(esa->sequences.oisfile.content != NULL &&
00058 esa->sequences.oisfile.occupied != esa->sequences.total_length.VU)
00059 {
00060 fid_error_throw(error,"Size of \"%s.ois\" (%lu) does not "
00061 "match size stored in project file (" UINTFMT ").",
00062 project->prjbasename,
00063 (unsigned long)esa->sequences.oisfile.occupied,
00064 esa->sequences.total_length.VU);
00065 retcode=-1;
00066 }
00067 }
00068
00069 if((tables&(fid_TABLE_TIS|fid_TABLE_OIS)) != 0)
00070 {
00071 if(esa->sequences.num_of_sequences.VU != project->num_of_sequences)
00072 {
00073 fid_error_throw(error,"Number of sequences stored in project \"%s\" "
00074 "(" fid_U64FMT ") does not match real number of "
00075 "sequences (" UINTFMT ").",
00076 project->prjbasename,project->num_of_sequences,
00077 esa->sequences.num_of_sequences.VU);
00078 retcode=-1;
00079 }
00080
00081 if(esa->sequences.total_length.VU != project->totallength)
00082 {
00083 fid_error_throw(error,"Size of sequences stored in project \"%s\" "
00084 "(" fid_U64FMT ") does not match real sequence size "
00085 "(" UINTFMT ").",
00086 project->prjbasename,project->totallength,
00087 esa->sequences.total_length.VU);
00088 retcode=-1;
00089 }
00090 }
00091
00092 if((tables&fid_TABLE_LCP) != 0)
00093 {
00094 if(esa->llvfile.content == NULL)
00095 {
00096 if(esa->num_of_large_lcps.VU > 0)
00097 {
00098 fid_error_throw(error,"Number of large LCP values stored in "
00099 "project file is " UINTFMT ", but file "
00100 "\"%s.llv\" not found.",
00101 esa->num_of_large_lcps.VU,project->prjbasename);
00102 retcode=-1;
00103 }
00104 }
00105 else if(esa->llvfile.occupied != esa->num_of_large_lcps.VU*2*project->integer_size_in_bytes ||
00106 esa->num_of_large_lcps.VU != project->large_lcp_values)
00107 {
00108 fid_error_throw(error,"Size of \"%s.llv\", %lu, does "
00109 "not match the number of large LCP values, "
00110 UINTFMT ", stored in project file.",
00111 project->prjbasename,
00112 (unsigned long)esa->llvfile.occupied,
00113 esa->num_of_large_lcps.VU);
00114 retcode=-1;
00115 }
00116 }
00117
00118 return retcode;
00119 }
00120
00121
00122
00123 static void init_from_esa(fid_Projectfile *project, const fid_Suffixarray *esa)
00124 {
00125 const fid_Symbol *seq, *ptr, *max;
00126 fid_Suffixinterval si;
00127
00128 project->totallength=esa->sequences.total_length.VU;
00129 project->num_of_sequences=esa->sequences.num_of_sequences.VU;
00130 project->large_lcp_values=esa->num_of_large_lcps.VU;
00131
00132
00133 if((seq=esa->sequences.tisfile.content) == NULL) return;
00134
00135 for(ptr=seq, max=ptr+esa->sequences.total_length.VU;
00136 ptr < max && fid_SPECIALSYMBOL(*ptr);
00137 ++ptr)
00138 {
00139 ++project->len_of_special_prefix;
00140 }
00141 for(ptr=max; ptr > seq && fid_SPECIALSYMBOL(*(ptr-1)); --ptr)
00142 {
00143 ++project->len_of_special_suffix;
00144 }
00145
00146
00147 if(esa->suftab.VU == NULL) return;
00148
00149 fid_suffixinterval_init_root(&si,esa);
00150 if(fid_suffixarray_find_embedded_interval(esa,&si,fid_WILDCARD) == 0)
00151 {
00152 project->num_of_specials=si.right-si.left+1;
00153 while(si.left <= si.right)
00154 {
00155 if(esa->suftab.VU[si.left] == 0 ||
00156 fid_REGULARSYMBOL(seq[esa->suftab.VU[si.left]-1]))
00157 {
00158 ++project->num_of_special_ranges;
00159 }
00160 ++si.left;
00161 }
00162 }
00163 }