1 /* $Id: indexdb.h 222798 2020-06-03 21:55:53Z twu $ */
2 #ifndef INDEXDB_INCLUDED
3 #define INDEXDB_INCLUDED
4 #ifdef HAVE_CONFIG_H
5 #include <config.h>		/* For HAVE_64_BIT */
6 #endif
7 
8 #include <stdio.h>
9 #include "access.h"
10 #include "types.h"
11 #include "univcoord.h"
12 #include "mode.h"
13 #include "genomicpos.h"
14 #include "bool.h"
15 #include "iitdef.h"
16 
17 #ifdef PMAP
18 #include "alphabet.h"
19 #endif
20 
21 
22 #ifdef PMAP
23 #define SUFFICIENT_SUPPORT 9
24 #else
25 #define SUFFICIENT_SUPPORT 18
26 #endif
27 
28 
29 #define T Indexdb_T
30 typedef struct T *T;
31 
32 #ifdef PMAP
33 extern void
34 Indexdb_setup (Width_T index1part_aa_in);
35 #else
36 extern void
37 Indexdb_setup (Width_T index1part_in);
38 #endif
39 
40 extern void
41 Indexdb_free (T *old);
42 #ifndef PMAP
43 extern Width_T
44 Indexdb_interval (T this);
45 #endif
46 extern bool
47 Indexdb_positions_fileio_p (T this);
48 extern double
49 Indexdb_mean_size (T this, Mode_T mode, Width_T index1part);
50 
51 
52 typedef struct Indexdb_filenames_T *Indexdb_filenames_T;
53 struct Indexdb_filenames_T {
54   char *pages_filename;
55   char *pointers_filename;
56   char *offsets_filename;
57   char *positions_high_filename;
58   char *positions_filename;
59 
60   char *pointers_basename_ptr;
61   char *offsets_basename_ptr;
62   char *positions_high_basename_ptr;
63   char *positions_basename_ptr;
64 
65   char *pointers_index1info_ptr;
66   char *offsets_index1info_ptr;
67   char *positions_high_index1info_ptr;
68   char *positions_index1info_ptr;
69 };
70 
71 
72 extern void
73 Indexdb_filenames_free (Indexdb_filenames_T *old);
74 
75 extern Indexdb_filenames_T
76 Indexdb_get_filenames (int *compression_type,
77 #ifdef PMAP
78 		       Alphabet_T *alphabet, Alphabet_T required_alphabet,
79 #endif
80 		       Width_T *index1part, Width_T *index1interval, char *genomesubdir,
81 		       char *fileroot, char *idx_filesuffix, char *snps_root,
82 		       Width_T required_index1part, Width_T required_interval,
83 		       bool offsets_only_p);
84 
85 extern Univcoord_T *
86 Indexdb_point_one_shift (int *nentries, T this, Oligospace_T subst);
87 extern int
88 Indexdb_count_one_shift (T this, Oligospace_T subst, int nadjacent);
89 
90 
91 extern Positionsptr_T *
92 Indexdb_offsets_from_bitpack (char *offsetsmetafile, char *offsetsstrmfile,
93 #ifdef PMAP
94 			      int alphabet_size, Width_T index1part_aa
95 #else
96 			      Width_T index1part
97 #endif
98 			      );
99 
100 #if defined(HAVE_64_BIT) && defined(UTILITYP)
101 extern Hugepositionsptr_T *
102 Indexdb_offsets_from_bitpack_huge (char *bitpackpagesfile, char *offsetsmetafile, char *offsetsstrmfile,
103 #ifdef PMAP
104 				   int alphabet_size, Width_T index1part_aa
105 #else
106 				   Width_T index1part
107 #endif
108 				   );
109 #endif
110 
111 #if 0
112 extern void
113 Indexdb_shmem_remove (char *genomesubdir, char *fileroot, char *idx_filesuffix, char *snps_root,
114 #ifdef PMAP
115 		      Alphabet_T *alphabet, int *alphabet_size, Alphabet_T required_alphabet,
116 #endif
117 		      Width_T required_index1part, Width_T required_interval, bool expand_offsets_p);
118 #endif
119 
120 extern T
121 Indexdb_new_genome (Width_T *index1part, Width_T *index1interval,
122 		    char *genomesubdir, char *fileroot, char *idx_filesuffix, char *snps_root,
123 #ifdef PMAP
124 		    Alphabet_T *alphabet, int *alphabet_size, Alphabet_T required_alphabet,
125 #endif
126 		    Width_T required_index1part, Width_T required_interval,
127 		    Access_mode_T offsetsstrm_access, Access_mode_T positions_access, bool sharedp,
128 		    bool multiple_sequences_p, bool preload_shared_memory_p, bool unload_shared_memory_p);
129 
130 extern T
131 Indexdb_new_transcriptome (Width_T *index1part, Width_T *index1interval,
132 			   char *genomesubdir, char *fileroot, char *idx_filesuffix, char *snps_root,
133 #ifdef PMAP
134 			   Alphabet_T *alphabet, int *alphabet_size, Alphabet_T required_alphabet,
135 #endif
136 			   Width_T required_index1part, Width_T required_interval,
137 			   Access_mode_T offsetsstrm_access, Access_mode_T positions_access, bool sharedp,
138 			   bool multiple_sequences_p, bool preload_shared_memory_p, bool unload_shared_memory_p);
139 
140 #ifndef UTILITYP
141 extern T
142 Indexdb_new_segment (char *genomicseg,
143 #ifdef PMAP
144 		     int alphabet_size, Width_T index1part_aa, bool watsonp,
145 #else
146 		     Width_T index1part,
147 #endif
148 		     Width_T index1interval);
149 #endif
150 
151 #ifdef PMAP
152 extern Univcoord_T *
153 Indexdb_read (int *nentries, T this, Oligospace_T aaindex);
154 #else
155 extern Univcoord_T *
156 Indexdb_read (int *nentries, T this, Oligospace_T oligo);
157 extern UINT4 *
158 Indexdb_read_inplace (int *nentries,
159 #ifdef LARGE_GENOMES
160 		      unsigned char **positions_high,
161 #endif
162 		      T this, Oligospace_T oligo);
163 #endif
164 
165 #ifdef LARGE_GENOMES
166 extern int
167 Indexdb_largeptr (unsigned char **positions_high, UINT4 **positions_low,
168 		  T this, Oligospace_T oligo);
169 #endif
170 
171 extern int
172 Indexdb_ptr (UINT4 **positions, T this, Oligospace_T oligo);
173 
174 #if defined(UTILITYP)
175 #elif defined(GSNAP)
176 #else
177 extern Univcoord_T *
178 Indexdb_read_with_diagterm (int *nentries, T this, Oligospace_T oligo, int diagterm);
179 #endif
180 
181 #undef T
182 #endif
183 
184