File: list_of_lists.h

package info (click to toggle)
phast 1.5%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 13,008 kB
  • sloc: ansic: 54,195; makefile: 358; sh: 337; perl: 321
file content (295 lines) | stat: -rw-r--r-- 9,539 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
#include <lists.h>
#include <tree_model.h>
#include <ms.h>
/* Recursive list structure emulating R's lists.  List of particular list types:
   char*, integer, or double currently supported */

/** @file list_of_lists.h
   Recursive list structure and supporting functions.

   Recursive list structure emulating R's lists.  List of particular list types:
   char*, integer, or double currently supported.  Makes use of singular list in lists.h.
   @ingroup base
   @see lists.h
*/


#ifndef __LIST_OF_LISTS__
#define __LIST_OF_LISTS__
/** List types supported */
typedef enum { INT_LIST, /**< List of Integers */
	       DBL_LIST, /**< List of Doubles */
	       CHAR_LIST,  /**< List of Chars */
		   MSA_PTR_LIST, /**< List of data from MSAs */
		   GFF_PTR_LIST, /**< List of data from GFFs */
	       LIST_LIST,  /**< List of Lists */
	       MS_PTR_LIST, /**< List of MSs */
	      } list_element_type;

/** Basic List of Lists object used recursively to create List of Lists  
*/
struct list_of_list_struct {
  List *lst;      /**< list of lists;  Each element can be be a List * 
                  containing ints, doubles, or char*, OR an element can
                  be a ListOfList*. */
  List *lstName;  /**< list of char* giving name of each element of lst */
  List *lstType;  /**< list of list_element_type giving type of each element in lst */
  char *class;    /**< NULL if this should be treated as a list; otherwise tells
                  R to coerce this list into this type of element (ie,
                  "matrix", "data.frame", "tm") */
};

typedef struct list_of_list_struct ListOfLists;

/** \name List of List allocation/cleanup functions 
 \{ */

/** Create a new list of lists
  @param approx_size approximate size, this should be as close to the maximum size your list will be so the list doesn't have to be expanded which is computationally intensive
  @result newly created list of lists of size specified
*/
ListOfLists *lol_new(int approx_size);

/** Frees a list of lists
  @param[in,out] lol List of Lists
  @warning uses the lst_free method in lists.h for all lists other than chars
*/
void lol_free(ListOfLists *lol);


/** \name List of List push functions 
 \{ */

/** Append an object to a list of lists
  @param[in,out] lol List of Lists
  @param[in] data object to be added to list of lists
  @param[in] name name of object being added
  @param[in] listType what type of object is being added 
*/
void lol_push(ListOfLists *lol, void *data,
	      const char *name, 
	      list_element_type listType);

/** Append a list to list of lists
  @param[in,out] lol List of Lists
  @param[in] data List to be added to list of lists
  @param[in] name name of list being added
  @param[in] listType what type of list is being added 
  @see lol_push
*/
void lol_push_list(ListOfLists *lol, List *data, 
		   const char *name, list_element_type listType);

/** Append a list of lists to list of lists
  @param[in,out] lol List of Lists
  @param[in] data List of Lists to be added to list of lists
  @param[in] name name of list of lists being added
  @see lol_push
*/
void lol_push_lol(ListOfLists *lol, 
		  ListOfLists *data, const char *name);

/** Append a list of doubles to list of lists
  @param[in,out] lol List of Lists
  @param[in] vals Array of doubles to be added to list of lists
  @param[in] len number of doubles to be added to the list
  @param[in] name name of list of doubles being added
  @see lol_push
*/
void lol_push_dbl(ListOfLists *lol, double *vals, int len,
		  const char *name);
/** Append a list of integers to list of lists
  @param[in,out] lol List of Lists
  @param[in] vals Array of integers to be added to list of lists
  @param[in] len number of integers to be added to the list
  @param[in] name name of list of integers being added
  @see lol_push
*/
void lol_push_int(ListOfLists *lol, int *vals, int len, 
		  const char *name);

/** Append a *char string to list of lists
  @param[in,out] lol List of Lists
  @param[in] vals *char string to be added to list of lists
  @param[in] len length of string to be added to the list
  @param[in] name name of string being added
  @see lol_push
*/
void lol_push_charvec(ListOfLists *lol, char **vals, int len,
		      const char *name);

/** Append data from a Matrix to list of lists
  A single list is appended to the list of lists (lol).
  The appended list contains the matrix rows and names
  @code
  //Layout of list to append
  matrixList->
	     //Rows with their column number as name
	      1-> 	  (list)
		  //Data at row 1, column 1 through n
		  2.4	     (double)
		  2.5        (double)
		  ...	    
		   n	     (double)
	      2-> 	  (list)
		  ...
		  ...
		  ...
	      ...
	      n 	  (list)
		  ...
		  ...
		  ...
	      row.names-> (list)
		  //Row numbers
	          1	  (char string)
		  2	  (char string)
		  ...
		  n	  (char string)
  @endcode
  @param[in,out] lol List of Lists
  @param[in] mat Matrix to be added to list of lists
  @param[in] name name of the Matrix being added
  @see lol_push
*/
void lol_push_matrix(ListOfLists *lol, Matrix *mat, 
		     const char *name);

/** Append an MSA to list of lists
  @param[in,out] lol List of Lists
  @param[in] msa msa to be added to list of lists
  @param[in] name name of msa being added
  @see lol_push
*/
void lol_push_msa(ListOfLists *lol, MSA *msa, const char *name);

/** Append data from a Tree Model to list of lists.
  A single list is appended to the list of lists (lol).
  The appended list contains up to 13 lists as shown below (depending on available data)
  @code
  //Layout of list to append
  treeModList->
	      alphabet		(char string)
	      backgd 		(double)
	      rate.matrix 	(matrix)
	      subst.mod		(char string)
	      likelihood	(double)
	      alpha		(double)
	      nratecats		(int)
	      rate.consts	(double)
	      rate.weights	(double)
	      selection		(double)
	      tree		(char string)
	      root.leaf		(int)
	      alt.model->	(list)
		     	  model->	(list) //For each alternative model
			  	subst.mod	(char string)
	      		  	backgd		(double)
			  	rate.matrix	(matrix)
			  	selection	(double)
			  	bgc		(double)
			  	defn		(char string)
  @endcode
  @param[in,out] lol List of Lists
  @param[in] tm Tree Model to be added to list of lists
  @param[in] name name of Tree Model being added
  @see lol_push
*/
void lol_push_treeModel(ListOfLists *lol, TreeModel *tm,
			const char *name);

/** Append data from a GFF to list of lists.
    A single list is appended to the list of lists (lol).
    The appended list contains 5 to 9 lists as shown below (depending on available data)
    @code
    //Layout of list to append
     gffList->
              List of sequence names (char string)
	      List of source   	 (char string)
	      List of feature   	 (char string)
	      List of start     	 (int)
	      List of end       	 (int)
	      List of score	    	 (double)
	      List of strand    	 (char)
	      List of frame     	 (int)
	      List of attribute 	 (char)
  @endcode
  @param[in,out] lol List of Lists
  @param[in] gff Feature Set containing data to add to list of lists
  @param[in] name name of gff being added
  @see lol_push
*/
void lol_push_gff(ListOfLists *lol, GFF_Set *gff,
		  const char *name);

/** Append a GFF (via pointer) to list of lists 
  @param[in,out] lol List of Lists
  @param[in] gff Feature Set to add
  @param[in] name Name to refer to Feature Set by
*/
void lol_push_gff_ptr(ListOfLists *lol, GFF_Set *gff, const char *name);

/** Append a MSA (via pointer) to list of lists 
  @param lol[in,out] lol List of Lists
  @param[in] msa Multiple Alignment to add
  @param[in] name Name to refer to MSA by
*/
void lol_push_msa_ptr(ListOfLists *lol, MSA *msa, const char *name);

/** Append an MS to list of lists
  @param[in,out] lol List of Lists
  @param[in] ms ms to be added to list of lists
  @param[in] name name of ms being added
  @see lol_push
*/
void lol_push_ms_ptr(ListOfLists *lol, MS *ms, const char *name);

/** Append a Double Array to list of lists 
   @param lol[in,out] lol List of Lists
   @param data[in] Array of doubles to add 
   @param name[in] Name to refer to Double Array by
   @param ndim[in] Number of dimensions
   @param dimsize[in] Dimension size
   @param dimname[in] Dimension name
*/
void lol_push_dbl_array(ListOfLists *lol, void *data, char *name, 
			int ndim, int *dimsize, char ***dimname);


/** \} \name List Of Lists RPHAST functions.
    \{ */

/** Set a class of list of lists
  @param[in,out] lol List of Lists
  @param[in] class what type of data R should coerce this list into
  @note NULL if this is simply a list
*/
void lol_set_class(ListOfLists *lol, char *class);



/** \} \name List of Lists Search by Name
\{ */

/** Find a list by name & type.
    @param lol[in] List of Lists to search for list within
	@param lstName[in] Name of list to retrieve
	@param lstType[in] Type of list to retrieve i.e. MSA_PTR_LIST
	@result List identified by name if found, or NULL if not found
	@warning If multiple lists have the same name program will die
*/
List *lol_find_list(ListOfLists *lol, const char *lstName, 
		    list_element_type lstType);

/** Find a List of Lists within a List of Lists.
    @param lol List of Lists to search within
	@param name Name of List of Lists to retrieve
	@result List of Lists identified by name if found, or NULL if not found
	@warning If multiple lists have the same name program will die
*/
ListOfLists *lol_find_lol(ListOfLists *lol, const char *name);
/** \} */



#endif