| 89 | } |
| 90 | |
| 91 | cGenotypeBatch* LoadBatchWithInstSet(cWorld* world, const cString& filename, cInstSet* inst_set) |
| 92 | { |
| 93 | // conduit.NotifyComment(cString("Loading: ") + filename); |
| 94 | |
| 95 | cInitFile input_file(filename); |
| 96 | if (!input_file.WasOpened()) { |
| 97 | tConstListIterator<cString> err_it(input_file.GetErrors()); |
| 98 | const cString* errstr = NULL; |
| 99 | while ((errstr = err_it.Next())) conduit.SignalError(*errstr); |
| 100 | cString failstr(cStringUtil::Stringf("unable to load file: %s", *filename)); |
| 101 | // conduit.SignalError(failstr, 1); |
| 102 | } |
| 103 | |
| 104 | const cString filetype = input_file.GetFiletype(); |
| 105 | if (filetype != "genotype_data") { |
| 106 | // conduit.SignalError(cStringUtil::Stringf("unable to load files of type '%s'", *filetype), 1); |
| 107 | } |
| 108 | |
| 109 | if (world->GetVerbosity() >= VERBOSE_ON) { |
| 110 | // conduit.NotifyComment(cStringUtil::Stringf("Loading file of type: %s", *filetype)); |
| 111 | } |
| 112 | |
| 113 | |
| 114 | // Construct a linked list of data types that can be loaded... |
| 115 | tList< tDataEntryCommand<cAnalyzeGenotype> > output_list; |
| 116 | tListIterator< tDataEntryCommand<cAnalyzeGenotype> > output_it(output_list); |
| 117 | cAnalyzeGenotype::GetDataCommandManager().LoadCommandList(input_file.GetFormat(), output_list); |
| 118 | bool id_inc = input_file.GetFormat().HasString("id"); |
| 119 | |
| 120 | // Setup the genome... |
| 121 | Sequence default_genome(1); |
| 122 | int load_count = 0; |
| 123 | cGenotypeBatch* batch = new cGenotypeBatch; |
| 124 | |
| 125 | for (int line_id = 0; line_id < input_file.GetNumLines(); line_id++) { |
| 126 | cString cur_line = input_file.GetLine(line_id); |
| 127 | |
| 128 | cAnalyzeGenotype* genotype = new cAnalyzeGenotype(world, default_genome, *inst_set); |
| 129 | |
| 130 | output_it.Reset(); |
| 131 | tDataEntryCommand<cAnalyzeGenotype>* data_command = NULL; |
| 132 | while ((data_command = output_it.Next())) data_command->SetValue(genotype, cur_line.PopWord()); |
| 133 | |
| 134 | // Give this genotype a name. Base it on the ID if possible. |
| 135 | if (id_inc == false) genotype->SetName(cStringUtil::Stringf("org-%d", load_count++)); |
| 136 | else genotype->SetName(cStringUtil::Stringf("org-%d", genotype->GetID())); |
| 137 | |
| 138 | // Add this genotype to the proper batch. |
| 139 | batch->List().PushRear(genotype); |
| 140 | } |
| 141 | |
| 142 | // Adjust the flags on this batch |
| 143 | batch->SetLineage(false); |
| 144 | batch->SetAligned(false); |
| 145 | |
| 146 | return batch; |
| 147 | } |
| 148 |
no test coverage detected