@@ -40,11 +40,11 @@ TEST_GROUP(FamilyTests)
40
40
TEST (FamilyTests, TestCafeFamily)
41
41
{
42
42
std::ifstream ifst (" Nonexistent.tab" );
43
- POINTERS_EQUAL (NULL , load_gene_families (ifst, 1 , ' \t ' ));
43
+ POINTERS_EQUAL (NULL , load_gene_families (ifst, ' \t ' , - 1 ));
44
44
45
45
pCafeFamily fam = cafe_family_init ({ " Dog" , " Chimp" , " Human" , " Mouse" , " Rat" });
46
46
47
- cafe_family_add_item (fam, { " OTOPETRIN " , " ENSF1 " , " 3 " , " 5 " , " 7 " , " 11 " , " 13 " });
47
+ cafe_family_add_item (fam, " ENSF1 " , " OTOPETRIN " , { 3 , 5 , 7 , 11 , 13 });
48
48
49
49
LONGS_EQUAL (5 , fam->num_species );
50
50
LONGS_EQUAL (1 , fam->flist ->size );
@@ -65,10 +65,10 @@ TEST(FamilyTests, TestCafeFamily)
65
65
TEST (FamilyTests, load_gene_families_tab_separated)
66
66
{
67
67
std::ifstream ifst (" Nonexistent.tab" );
68
- POINTERS_EQUAL (NULL , load_gene_families (ifst, 1 , ' \t ' ));
68
+ POINTERS_EQUAL (NULL , load_gene_families (ifst, ' \t ' , - 1 ));
69
69
70
70
std::istringstream ist (" FAMILYDESC\t FAMILY\t A\t B\n OTOPETRIN\t ENSF2\t 2\t 10\n " );
71
- pCafeFamily fam = load_gene_families (ist, 0 , ' \t ' );
71
+ pCafeFamily fam = load_gene_families (ist, ' \t ' , - 1 );
72
72
LONGS_EQUAL (2 , fam->num_species );
73
73
STRCMP_EQUAL (" A" , fam->species [0 ]);
74
74
STRCMP_EQUAL (" B" , fam->species [1 ]);
@@ -83,10 +83,25 @@ TEST(FamilyTests, load_gene_families_tab_separated)
83
83
cafe_family_free (fam);
84
84
}
85
85
86
+ TEST (FamilyTests, filter_families_greater_than_max_size)
87
+ {
88
+ std::istringstream ist (" FAMILYDESC\t FAMILY\t A\t B\n desc\t id1\t 2\t 50\n desc\t id2\t 20\t 10\n " );
89
+ pCafeFamily fam = load_gene_families (ist, ' \t ' , 25 );
90
+ LONGS_EQUAL (2 , fam->num_species );
91
+ STRCMP_EQUAL (" A" , fam->species [0 ]);
92
+ STRCMP_EQUAL (" B" , fam->species [1 ]);
93
+
94
+ LONGS_EQUAL (1 , fam->flist ->size );
95
+
96
+ CHECK (get_family_item (fam, " id1" ) == NULL );
97
+ CHECK (get_family_item (fam, " id2" ) != NULL );
98
+ cafe_family_free (fam);
99
+ }
100
+
86
101
TEST (FamilyTests, load_gene_families_comma_separated)
87
102
{
88
103
std::istringstream ist (" FAMILY DESC,FAMILY,A,B\n OXYSTEROL BINDING RELATED,ENSF2,2,10\n " );
89
- pCafeFamily fam = load_gene_families (ist, 0 , ' ,' );
104
+ pCafeFamily fam = load_gene_families (ist, ' ,' , - 1 );
90
105
LONGS_EQUAL (2 , fam->num_species );
91
106
STRCMP_EQUAL (" A" , fam->species [0 ]);
92
107
STRCMP_EQUAL (" B" , fam->species [1 ]);
@@ -106,7 +121,7 @@ TEST(FamilyTests, load_gene_families_is_not_whitespace_separated)
106
121
std::istringstream ist (" FAMILYDESC FAMILY A B C\n " );
107
122
try
108
123
{
109
- pCafeFamily fam = load_gene_families (ist, 0 , ' \t ' );
124
+ pCafeFamily fam = load_gene_families (ist, ' \t ' , - 1 );
110
125
FAIL (" Exception should have been thrown" );
111
126
cafe_family_free (fam);
112
127
}
@@ -119,7 +134,7 @@ TEST(FamilyTests, load_gene_families_is_not_whitespace_separated)
119
134
TEST (FamilyTests, cafe_family_set_size)
120
135
{
121
136
pCafeFamily pcf = cafe_family_init ({" chimp" , " human" , " mouse" , " rat" , " dog" });
122
- cafe_family_add_item (pcf, { " description " , " id " , " 3 " , " 5 " , " 7 " , " 11 " , " 13 " });
137
+ cafe_family_add_item (pcf, " id " , " description " , { 3 , 5 , 7 , 11 , 13 });
123
138
124
139
pCafeTree ptree = create_tree ();
125
140
cafe_family_set_species_index (pcf, ptree);
@@ -155,7 +170,7 @@ TEST(FamilyTests, cafe_family_add_item)
155
170
{
156
171
pCafeFamily pcf = cafe_family_init ({" chimp" , " human" , " mouse" , " rat" , " dog" });
157
172
158
- cafe_family_add_item (pcf, { " description " , " id " , " 3 " , " 5 " , " 7 " , " 11 " , " 13 " });
173
+ cafe_family_add_item (pcf, " id " , " description " , { 3 , 5 , 7 , 11 , 13 });
159
174
LONGS_EQUAL (1 , pcf->flist ->size );
160
175
pCafeFamilyItem pitem = (pCafeFamilyItem)arraylist_get (pcf->flist , 0 );
161
176
STRCMP_EQUAL (" description" , pitem->desc );
@@ -203,7 +218,7 @@ TEST(FamilyTests, cafe_family_set_size_with_family_forced)
203
218
pCafeFamily pcf = cafe_family_init ({" chimp" , " human" , " mouse" , " rat" , " dog" });
204
219
pCafeTree cafe_tree = create_tree ();
205
220
cafe_family_set_species_index (pcf, cafe_tree);
206
- cafe_family_add_item (pcf, { " description " , " id " , " 3 " , " 5 " , " 7 " , " 11 " , " 13 " });
221
+ cafe_family_add_item (pcf, " id " , " description " , { 3 , 5 , 7 , 11 , 13 });
207
222
208
223
// SUT
209
224
cafe_family_set_size_with_family_forced (pcf, 0 , cafe_tree);
@@ -218,7 +233,7 @@ TEST(FamilyTests, write_family_gainloss)
218
233
{
219
234
std::ostringstream ost;
220
235
pCafeFamily pcf = cafe_family_init ({" chimp" , " human" , " mouse" , " rat" , " dog" });
221
- cafe_family_add_item (pcf, { " description " , " id " , " 3 " , " 5 " , " 7 " , " 11 " , " 13 " });
236
+ cafe_family_add_item (pcf, " id " , " description " , { 3 , 5 , 7 , 11 , 13 });
222
237
pCafeTree tree1 = create_tree ();
223
238
cafe_family_set_species_index (pcf, tree1);
224
239
pCafeTree tree2 = cafe_tree_copy (tree1);
@@ -237,11 +252,11 @@ TEST(FamilyTests, write_family)
237
252
{
238
253
std::ostringstream ost;
239
254
pCafeFamily pcf = cafe_family_init ({" chimp" , " human" , " mouse" , " rat" , " dog" });
240
- cafe_family_add_item (pcf, { " my_description " , " my_id " , " 3 " , " 5 " , " 7 " , " 11 " , " 13 " });
255
+ cafe_family_add_item (pcf, " id " , " description " , { 3 , 5 , 7 , 11 , 13 });
241
256
242
257
write_family (ost, pcf);
243
258
STRCMP_CONTAINS (" Desc\t Family ID\t chimp\t human\t mouse\t rat\t dog\n " , ost.str ().c_str ())
244
- STRCMP_CONTAINS (" my_description \t my_id \t 3\t 5\t 7\t 11\t 13\n " , ost.str ().c_str ())
259
+ STRCMP_CONTAINS (" description \t id \t 3\t 5\t 7\t 11\t 13\n " , ost.str ().c_str ())
245
260
cafe_family_free (pcf);
246
261
247
262
}
@@ -250,13 +265,13 @@ TEST(FamilyTests, log_cluster_membership)
250
265
{
251
266
std::ostringstream ost;
252
267
pCafeFamily pcf = cafe_family_init ({ " chimp" , " human" , " mouse" , " rat" , " dog" });
253
- cafe_family_add_item (pcf, { " my_description " , " my_id " , " 3 " , " 5 " , " 7 " , " 11 " , " 13 " });
268
+ cafe_family_add_item (pcf, " id " , " description " , { 3 , 5 , 7 , 11 , 13 });
254
269
double **z = (double **)memory_new_2dim (2 , 2 , sizeof (double ));
255
270
z[0 ][0 ] = 7.7 ;
256
271
z[0 ][1 ] = 11.13 ;
257
272
log_cluster_membership (pcf, 2 , z, ost);
258
273
STRCMP_CONTAINS (" The Number of families : 1\n " , ost.str ().c_str ());
259
- STRCMP_CONTAINS (" family my_id : 7.7 11.13" , ost.str ().c_str ());
274
+ STRCMP_CONTAINS (" family id : 7.7 11.13" , ost.str ().c_str ());
260
275
261
276
cafe_family_free (pcf);
262
277
}
0 commit comments