1 /* @include enscoordsystem ****************************************************
2 **
3 ** Ensembl Coordinate System functions
4 **
5 ** @author Copyright (C) 1999 Ensembl Developers
6 ** @author Copyright (C) 2006 Michael K. Schuster
7 ** @version $Revision: 1.22 $
8 ** @modified 2009 by Alan Bleasby for incorporation into EMBOSS core
9 ** @modified $Date: 2013/02/17 13:04:02 $ by $Author: mks $
10 ** @@
11 **
12 ** This library is free software; you can redistribute it and/or
13 ** modify it under the terms of the GNU Lesser General Public
14 ** License as published by the Free Software Foundation; either
15 ** version 2.1 of the License, or (at your option) any later version.
16 **
17 ** This library is distributed in the hope that it will be useful,
18 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
19 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
20 ** Lesser General Public License for more details.
21 **
22 ** You should have received a copy of the GNU Lesser General Public
23 ** License along with this library; if not, write to the Free Software
24 ** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
25 ** MA  02110-1301,  USA.
26 **
27 ******************************************************************************/
28 
29 #ifndef ENSCOORDSYSTEM_H
30 #define ENSCOORDSYSTEM_H
31 
32 /* ========================================================================= */
33 /* ============================= include files ============================= */
34 /* ========================================================================= */
35 
36 #include "ensdatabaseadaptor.h"
37 
38 AJ_BEGIN_DECLS
39 
40 
41 
42 
43 /* ========================================================================= */
44 /* =============================== constants =============================== */
45 /* ========================================================================= */
46 
47 
48 
49 
50 /* ========================================================================= */
51 /* ============================== public data ============================== */
52 /* ========================================================================= */
53 
54 struct EnsSCoordsystem;
55 
56 
57 
58 
59 /* @data EnsPCoordsystemadaptor ***********************************************
60 **
61 ** Ensembl Coordinate System Adaptor
62 **
63 ** @alias EnsSCoordsystemadaptor
64 ** @alias EnsOCoordsystemadaptor
65 **
66 ** @cc Bio::EnsEMBL::DBSQL::BaseAdaptor
67 ** @attr Adaptor [EnsPDatabaseadaptor] Ensembl Database Adaptor
68 ** cc Bio::EnsEMBL::DBSQL::CoordSystemAdaptor
69 ** @attr CacheByIdentifier [AjPTable] Database identifier cache
70 ** @attr CacheByName [AjPTable] Name cache
71 ** @attr CacheByRank [AjPTable] Rank cache
72 ** @attr CacheByDefault [AjPTable] Default Ensembl Coordinate System objects
73 ** @attr MappingPaths [AjPTable] Mapping paths between coordinate systems
74 ** @attr ExternalToInternal [AjPTable]
75 ** AJAX Table of AJAX unsigned integer
76 ** (external Ensembl Sequence Region identifier) key data and
77 ** AJAX unsigned integer
78 ** (internal Ensembl Sequence Region identifier) value data
79 ** @attr InternalToExternal [AjPTable]
80 ** AJAX Table of AJAX unsigned integer
81 ** (internal Ensembl Sequence Region identifier) key data and
82 ** AJAX unsigned integer
83 ** (external Ensembl Sequence Region identifier) value data
84 ** @attr Seqlevel [struct EnsSCoordsystem*]
85 ** Sequence-level Ensembl Coordinate System
86 ** @attr Toplevel [struct EnsSCoordsystem*]
87 ** Top-level Ensembl Coordinate System
88 ** @@
89 ******************************************************************************/
90 
91 typedef struct EnsSCoordsystemadaptor
92 {
93     EnsPDatabaseadaptor Adaptor;
94     AjPTable CacheByIdentifier;
95     AjPTable CacheByName;
96     AjPTable CacheByRank;
97     AjPTable CacheByDefault;
98     AjPTable MappingPaths;
99     AjPTable ExternalToInternal;
100     AjPTable InternalToExternal;
101     struct EnsSCoordsystem *Seqlevel;
102     struct EnsSCoordsystem *Toplevel;
103 } EnsOCoordsystemadaptor;
104 
105 #define EnsPCoordsystemadaptor EnsOCoordsystemadaptor*
106 
107 
108 
109 
110 /* @data EnsPCoordsystem ******************************************************
111 **
112 ** Ensembl Coordinate System
113 **
114 ** @alias EnsSCoordsystem
115 ** @alias EnsOCoordsystem
116 **
117 ** @attr Use [ajuint] Use counter
118 ** @cc Bio::EnsEMBL::Storable
119 ** @attr Identifier [ajuint] Internal SQL database identifier (primary key)
120 ** @attr Adaptor [EnsPCoordsystemadaptor] Ensembl Coordinate System Adaptor
121 ** @cc Bio::EnsEMBL::CoordSystem
122 ** @attr Name [AjPStr] Coordinate System name
123 ** @attr Version [AjPStr] Coordinate System version
124 ** @attr Default [AjBool] Default Coordinate System version of this name
125 ** @attr SequenceLevel [AjBool] Sequence-level attribute
126 ** @attr Toplevel [AjBool] Top-level attribute
127 ** @attr Rank [ajuint] Coordinate System rank
128 ** @@
129 ******************************************************************************/
130 
131 typedef struct EnsSCoordsystem
132 {
133     ajuint Use;
134     ajuint Identifier;
135     EnsPCoordsystemadaptor Adaptor;
136     AjPStr Name;
137     AjPStr Version;
138     AjBool Default;
139     AjBool SequenceLevel;
140     AjBool Toplevel;
141     ajuint Rank;
142 } EnsOCoordsystem;
143 
144 #define EnsPCoordsystem EnsOCoordsystem*
145 
146 
147 
148 
149 /* ========================================================================= */
150 /* =========================== public functions ============================ */
151 /* ========================================================================= */
152 
153 /*
154 ** Prototype definitions
155 */
156 
157 /* Ensembl Coordinate System */
158 
159 EnsPCoordsystem ensCoordsystemNewCpy(const EnsPCoordsystem cs);
160 
161 EnsPCoordsystem ensCoordsystemNewIni(EnsPCoordsystemadaptor csa,
162                                      ajuint identifier,
163                                      AjPStr name,
164                                      AjPStr version,
165                                      ajuint rank,
166                                      AjBool deflt,
167                                      AjBool toplvl,
168                                      AjBool seqlvl);
169 
170 EnsPCoordsystem ensCoordsystemNewRef(EnsPCoordsystem cs);
171 
172 void ensCoordsystemDel(EnsPCoordsystem *Pcs);
173 
174 EnsPCoordsystemadaptor ensCoordsystemGetAdaptor(const EnsPCoordsystem cs);
175 
176 AjBool ensCoordsystemGetDefault(const EnsPCoordsystem cs);
177 
178 ajuint ensCoordsystemGetIdentifier(const EnsPCoordsystem cs);
179 
180 const AjPStr ensCoordsystemGetName(const EnsPCoordsystem cs);
181 
182 ajuint ensCoordsystemGetRank(const EnsPCoordsystem cs);
183 
184 AjBool ensCoordsystemGetSeqlevel(const EnsPCoordsystem cs);
185 
186 AjBool ensCoordsystemGetToplevel(const EnsPCoordsystem cs);
187 
188 const AjPStr ensCoordsystemGetVersion(const EnsPCoordsystem cs);
189 
190 AjBool ensCoordsystemSetAdaptor(EnsPCoordsystem cs,
191                                 EnsPCoordsystemadaptor csa);
192 
193 AjBool ensCoordsystemSetIdentifier(EnsPCoordsystem cs, ajuint identifier);
194 
195 AjBool ensCoordsystemTrace(const EnsPCoordsystem cs, ajuint level);
196 
197 size_t ensCoordsystemCalculateMemsize(const EnsPCoordsystem cs);
198 
199 AjBool ensCoordsystemMatch(const EnsPCoordsystem cs1,
200                            const EnsPCoordsystem cs2);
201 
202 AjPStr ensCoordsystemGetSpecies(const EnsPCoordsystem cs);
203 
204 AjBool ensListCoordsystemSortIdentifierAscending(AjPList css);
205 
206 AjBool ensListCoordsystemSortIdentifierDescending(AjPList css);
207 
208 AjBool ensListCoordsystemSortRankAscending(AjPList css);
209 
210 AjBool ensListCoordsystemSortRankDescending(AjPList css);
211 
212 AjBool ensListCoordsystemTrace(const AjPList css, ajuint level);
213 
214 /* Ensembl Coordinate System Adaptor */
215 
216 EnsPCoordsystemadaptor ensRegistryGetCoordsystemadaptor(
217     EnsPDatabaseadaptor dba);
218 
219 EnsPCoordsystemadaptor ensCoordsystemadaptorNew(
220     EnsPDatabaseadaptor dba);
221 
222 void ensCoordsystemadaptorDel(EnsPCoordsystemadaptor *Pcsa);
223 
224 EnsPDatabaseadaptor ensCoordsystemadaptorGetDatabaseadaptor(
225     EnsPCoordsystemadaptor csa);
226 
227 AjBool ensCoordsystemadaptorFetchAll(
228     const EnsPCoordsystemadaptor csa,
229     AjPList css);
230 
231 AjBool ensCoordsystemadaptorFetchAllbyName(
232     const EnsPCoordsystemadaptor csa,
233     const AjPStr name,
234     AjPList css);
235 
236 AjBool ensCoordsystemadaptorFetchByIdentifier(
237     const EnsPCoordsystemadaptor csa,
238     ajuint identifier,
239     EnsPCoordsystem *Pcs);
240 
241 AjBool ensCoordsystemadaptorFetchByName(
242     const EnsPCoordsystemadaptor csa,
243     const AjPStr name,
244     const AjPStr version,
245     EnsPCoordsystem *Pcs);
246 
247 AjBool ensCoordsystemadaptorFetchByRank(
248     const EnsPCoordsystemadaptor csa,
249     ajuint rank,
250     EnsPCoordsystem *Pcs);
251 
252 AjBool ensCoordsystemadaptorFetchSeqlevel(
253     const EnsPCoordsystemadaptor csa,
254     EnsPCoordsystem *Pcs);
255 
256 AjBool ensCoordsystemadaptorFetchToplevel(
257     const EnsPCoordsystemadaptor csa,
258     EnsPCoordsystem *Pcs);
259 
260 const AjPList ensCoordsystemadaptorGetMappingpath(
261     const EnsPCoordsystemadaptor csa,
262     EnsPCoordsystem cs1,
263     EnsPCoordsystem cs2);
264 
265 ajuint ensCoordsystemadaptorGetSeqregionidentifierExternal(
266     const EnsPCoordsystemadaptor csa,
267     ajuint srid);
268 
269 ajuint ensCoordsystemadaptorGetSeqregionidentifierInternal(
270     const EnsPCoordsystemadaptor csa,
271     ajuint srid);
272 
273 /*
274 ** End of prototype definitions
275 */
276 
277 
278 
279 
280 AJ_END_DECLS
281 
282 #endif /* !ENSCOORDSYSTEM_H */
283