1 /* @include ajdmx *************************************************************
2 **
3 ** AJAX objects for some of the DOMAINATRIX EMBASSY applications.
4 ** Scophit and Scopalg objects.
5 **
6 ** @author: Copyright (C) 2004 Ranjeeva Ranasinghe (rranasin@hgmp.mrc.ac.uk)
7 ** @author: Copyright (C) 2004 Jon Ison (jison@hgmp.mrc.ac.uk)
8 ** @version $Revision: 1.23 $
9 ** @modified $Date: 2012/04/12 20:36:03 $ 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 AJDMX_H
30 #define AJDMX_H
31 
32 /* ========================================================================= */
33 /* ============================= include files ============================= */
34 /* ========================================================================= */
35 
36 #include "ajdefine.h"
37 #include "ajstr.h"
38 #include "ajlist.h"
39 #include "ajfile.h"
40 #include "ajpdb.h"
41 #include "ajdomain.h"
42 
43 AJ_BEGIN_DECLS
44 
45 
46 
47 
48 /* ========================================================================= */
49 /* =============================== constants =============================== */
50 /* ========================================================================= */
51 
52 
53 
54 
55 /* ========================================================================= */
56 /* ============================== public data ============================== */
57 /* ========================================================================= */
58 
59 
60 
61 
62 /* @data AjPScophit ***********************************************************
63 **
64 ** AJAX SCOP Hit object
65 **
66 ** Holds data associated with a protein / domain sequence. Includes SCOP
67 ** classification records.
68 **
69 ** AjPScophit is implemented as a pointer to a C data structure.
70 **
71 ** @alias AjSScophit
72 ** @alias AjOScophit
73 **
74 ** @attr Class [AjPStr] Class name
75 ** @attr Architecture [AjPStr] CATH classification.
76 ** @attr Topology [AjPStr] CATH classification.
77 ** @attr Fold [AjPStr] Fold name
78 ** @attr Superfamily [AjPStr] Superfamily name
79 ** @attr Family [AjPStr] Family name
80 ** @attr Type [AjEDomainType] AJAX Domain Type enumeration
81 ** @attr Sunid_Family [ajuint] Domain identifier of node (e.g. family or
82 ** superfamily) represented.
83 ** @attr Seq [AjPStr] Sequence as string
84 ** @attr Start [ajuint] Start of sequence or signature alignment
85 **       relative to full length swissprot sequence
86 ** @attr End [ajuint] End of sequence or signature alignment relative
87 **       to full length swissprot sequence
88 ** @attr Acc [AjPStr] Accession number of sequence entry
89 ** @attr Spr [AjPStr] Swissprot code of sequence entry
90 ** @attr Dom [AjPStr] SCOP or CATH database identifier code of entry.
91 ** @attr Typeobj [AjPStr] Bibliographic information ... objective
92 ** @attr Typesbj [AjPStr] Bibliographic information ... subjective
93 ** @attr Model [AjPStr] String for model type (HMM, Gribskov etc)
94 ** @attr Group [AjPStr] 'REDUNDANT' or 'NON_REDUNDANT'
95 ** @attr Rank [ajuint] Rank order of hit
96 ** @attr Score [float] Score of hit
97 ** @attr Eval [float] E-value of hit
98 ** @attr Pval [float] p-value of hit
99 ** @attr Alg [AjPStr] Alignment, e.g. of a signature to the sequence
100 ** @attr Target [AjBool] True if the Scophit is targeted for removal
101 **       from a list of Scophit objects
102 ** @attr Target2 [AjBool] Also used for garbage collection
103 ** @attr Priority [AjBool] True if the Scop hit is high priority
104 ** @attr Padding [char[4]] Padding to alignment boundary
105 **
106 ** @new    ajDmxScophitNew Default Scophit object constructor.
107 ** @delete ajDmxScophitDel Default Scophit object destructor.
108 ** @delete ajDmxScophitDelWrap Wrapper to destructor for Scophit object
109 **         for use with generic functions.
110 ** @assign ajDmxScophitListCopy Reads a list of Scophit structures and
111 **         returns a pointer to a duplicate of the list.
112 ** @use    ajDmxScophitCheckTarget Checks to see if the Target element of a
113 **         Scophit object == ajTrue.
114 ** @modify ajDmxScophitTarget Sets the Target element of a Scophit object
115 **         to True.
116 ** @modify ajDmxScophitTarget2 Sets the Target2 element of a Scophit object
117 **         to True.
118 ** @modify ajDmxScophitTargetLowPriority Sets the Target element of a
119 **         Scophit object to True if its Priority is low.
120 ** @use    ajDmxScophitCompSpr Function to sort Scophit object by Spr element.
121 ** @use    ajDmxScophitCompStart Function to sort Scophit object by Spr
122 **         element.
123 ** @use    ajDmxScophitCompEnd Function to sort Scophit object by End element.
124 ** @use    ajDmxScophitCompClass Function to sort Scophit object by Class
125 **         element.
126 ** @use    ajDmxScophitCompFold Function to sort Scophit object by Fold
127 **         element.
128 ** @use    ajDmxScophitCompSfam Function to sort Scophit object by Superfamily
129 **         element.
130 ** @use    ajDmxScophitCompFam Function to sort Scophit object by Family
131 **         element.
132 ** @use    ajDmxScophitCompAcc Function to sort Scophit objects by Acc element.
133 ** @use    ajDmxScophitCompSunid Function to sort Scophit objects by Sunid
134 **         element.
135 ** @use    ajDmxScophitCompScore Function to sort Scophit objects by Score
136 **         element.
137 ** @use    ajDmxScophitCompPval Function to sort Scophit objects by Pval
138 **         element.
139 ** @use    ajDmxScopSeqFromSunid Writes a sequence corresponding to a Scop
140 **         domain given a Sunid for the domain. The sequence is taken from one
141 **         of a list of Scop objects that is provided.
142 ** @output ajDmxScophitsWrite Write contents of a list of Scophits to an output
143 **         file.
144 ** @output ajDmxScophitsWriteFasta Write contents of a list of Scophits to an
145 **         output file in extended FASTA format.
146 ** @input  ajDmxScophitReadFasta Read a Scophit object from a file in
147 **         extended FASTA format.
148 ** @assign ajDmxScophitCopy Copies the contents from one Scophit object to
149 **         another.
150 ** @@
151 ******************************************************************************/
152 
153 typedef struct AjSScophit
154 {
155     AjPStr Class;
156     AjPStr Architecture;
157     AjPStr Topology;
158     AjPStr Fold;
159     AjPStr Superfamily;
160     AjPStr Family;
161     AjEDomainType Type;
162     ajuint Sunid_Family;
163     AjPStr Seq;
164     ajuint Start;
165     ajuint End;
166     AjPStr Acc;
167     AjPStr Spr;
168     AjPStr Dom;
169     AjPStr Typeobj;
170     AjPStr Typesbj;
171     AjPStr Model;
172     AjPStr Group;
173     ajuint Rank;
174     float Score;
175     float Eval;
176     float Pval;
177     AjPStr Alg;
178     AjBool Target;
179     AjBool Target2;
180     AjBool Priority;
181     char Padding[4];
182 } AjOScophit, *AjXScophit;
183 
184 #define AjPScophit AjOScophit*
185 #define AjPPScophit AjXScophit*
186 
187 
188 
189 
190 /* @data AjPScopalg ***********************************************************
191 **
192 ** AJAX SCOP Alignment object
193 **
194 ** Holds data associated with a structure alignment.
195 ** Now adapted to hold CATH domain data also by addition of Type,
196 ** Architecture and Topology elements.
197 **
198 ** AjPScopalg is implemented as a pointer to a C data structure.
199 **
200 ** @alias AjSScopalg
201 ** @alias AjOScopalg
202 **
203 ** @attr Class [AjPStr] Class name
204 ** @attr Architecture [AjPStr] CATH classification.
205 ** @attr Topology [AjPStr] CATH classification.
206 ** @attr Fold [AjPStr] Fold name
207 ** @attr Superfamily [AjPStr] Superfamily name
208 ** @attr Family [AjPStr] Family name (SCOP only)
209 ** @attr Sunid_Family [ajuint] SCOP sunid for family
210 ** @attr Width [ajuint] Width (residues) of widest part of alignment
211 ** @attr Type [AjEDomainType] AJAX Domain Type enumeration
212 ** @attr Number [ajuint] No. of sequences in alignment
213 ** @attr Codes [AjPStr*] Array of domain id codes of sequences
214 ** @attr Seqs [AjPStr*] Array of sequences
215 ** @attr Post_similar [AjPStr] Post_similar line from alignment
216 ** @attr Positions [AjPStr] Array of integers from 'Position' line in
217 **                            alignment, used for manual specification of
218 **                            signature positions
219 **
220 **
221 **
222 ** @new    ajDmxScopalgRead Read a Scopalg object from a file.
223 ** @output ajDmxScopalgWrite Write a Scopalg object to file in clustal format
224 **         annotated with SCOP classification info.
225 ** @output ajDmxScopalgWriteClustal Writes a Scopalg object to file in clustal
226 **         format (just the alignment without the SCOP classification
227 **         information).
228 ** @output ajDmxScopalgWriteClustal2 Writes a Scopalg object to file in clustal
229 **         format (just the alignment without the SCOP classification
230 **         information).
231 ** @output ajDmxScopalgWriteFasta Writes a Scopalg object to file in clustal
232 **         format (just the alignment without the SCOP classification
233 **         information).
234 ** @new    ajDmxScopalgNew Scopalg object constructor.
235 ** @delete ajDmxScopalgDel Scopalg object destructor.
236 ** @input  ajDmxScopalgGetseqs Read a Scopalg object and writes an array of
237 **         AjPStr containing the sequences without gaps.
238 ** @@
239 ******************************************************************************/
240 
241 typedef struct AjSScopalg
242 {
243     AjPStr Class;
244     AjPStr Architecture;
245     AjPStr Topology;
246     AjPStr Fold;
247     AjPStr Superfamily;
248     AjPStr Family;
249     ajuint Sunid_Family;
250     ajuint Width;
251     AjEDomainType Type;
252     ajuint Number;
253     AjPStr *Codes;
254     AjPStr *Seqs;
255     AjPStr Post_similar;
256     AjPStr Positions;
257 } AjOScopalg;
258 
259 #define AjPScopalg AjOScopalg*
260 
261 
262 
263 
264 /* ========================================================================= */
265 /* =========================== public functions ============================ */
266 /* ========================================================================= */
267 
268 
269 
270 
271 /*
272 ** Prototype definitions
273 */
274 
275 void          ajDmxDummyFunction(void);
276 void          ajDmxExit(void);
277 
278 
279 
280 
281 /* ======================================================================= */
282 /* ========================== Scophit object ============================= */
283 /* ======================================================================= */
284 
285 
286 
287 
288 AjPScophit    ajDmxScophitNew(void);
289 void          ajDmxScophitDel(AjPScophit *Pscophit);
290 void          ajDmxScophitDelWrap(void **Pitem);
291 AjPList       ajDmxScophitListCopy(const AjPList scophits);
292 
293 AjBool        ajDmxScophitCheckTarget(const AjPScophit scophit);
294 AjBool        ajDmxScophitTarget(AjPScophit *Pscophit);
295 AjBool        ajDmxScophitTarget2(AjPScophit *Pscophit);
296 AjBool        ajDmxScophitTargetLowPriority(AjPScophit *Pscophit);
297 
298 ajint         ajDmxScophitCompSpr(const void *item1, const void *item2);
299 ajint         ajDmxScophitCompStart(const void *item1, const void *item2);
300 ajint         ajDmxScophitCompEnd(const void *item1, const void *item2);
301 ajint         ajDmxScophitCompClass(const void *item1, const void *item2);
302 ajint         ajDmxScophitCompFold(const void *item1, const void *item2);
303 ajint         ajDmxScophitCompSfam(const void *item1, const void *item2);
304 ajint         ajDmxScophitCompFam(const void *item1, const void *item2);
305 ajint         ajDmxScophitCompAcc(const void *item1, const void *item2);
306 ajint         ajDmxScophitCompSunid(const void *item1, const void *item2);
307 ajint         ajDmxScophitCompScore(const void *item1, const void *item2);
308 ajint         ajDmxScophitCompPval(const void *item1, const void *item2);
309 
310 AjBool        ajDmxScopSeqFromSunid(ajint identifier, AjPStr *seq,
311                                     const AjPList scops);
312 AjBool        ajDmxScophitsWrite(AjPFile outf, const AjPList scophits);
313 AjBool        ajDmxScophitsWriteFasta(AjPFile outf, const AjPList scophits);
314 AjPScophit    ajDmxScophitReadFasta(AjPFile inf);
315 AjBool        ajDmxScophitCopy(AjPScophit *Pto, const AjPScophit from);
316 
317 
318 
319 
320 /* ======================================================================= */
321 /* ========================== Scopalg object ============================= */
322 /* ======================================================================= */
323 
324 
325 
326 
327 AjBool        ajDmxScopalgRead(AjPFile inf, AjPScopalg *Pscopalg);
328 AjBool        ajDmxScopalgWrite(const AjPScopalg scopalg, AjPFile outf);
329 AjBool        ajDmxScopalgWriteClustal(const AjPScopalg scopalg, AjPFile outf);
330 AjBool        ajDmxScopalgWriteClustal2(const AjPScopalg scopalg, AjPFile outf);
331 AjBool        ajDmxScopalgWriteFasta(const AjPScopalg scopalg, AjPFile outf);
332 AjPScopalg    ajDmxScopalgNew(ajuint n);
333 void          ajDmxScopalgDel(AjPScopalg *Pscopalg);
334 ajuint        ajDmxScopalgGetseqs(const AjPScopalg scopalg, AjPStr **array);
335 
336 /*
337 ** End of prototype definitions
338 */
339 
340 
341 
342 
343 AJ_END_DECLS
344 
345 #endif /* !AJDMX_H */
346