Skip to content

Commit 2983efb

Browse files
committed
Merge remote-tracking branch 'origin/mcmctree_dating_merged2' into onnxupdate-new-schedluing
2 parents ce084be + bb389ea commit 2983efb

21 files changed

+1334
-377
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -504,7 +504,7 @@ if (NOT IQTREE_FLAGS MATCHES "single")
504504
link_directories(${PROJECT_SOURCE_DIR}/libmac_m1)
505505
else()
506506
link_directories(${PROJECT_SOURCE_DIR}/libmac)
507-
endif()
507+
endif()
508508
elseif (UNIX AND NOT ${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD")
509509
if (__ARM_NEON)
510510
link_directories(${PROJECT_SOURCE_DIR}/liblinux_arm)

main/alisim.cpp

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ void runAliSim(Params &params, Checkpoint *checkpoint)
7171
if (inference_mode)
7272
{
7373
inferInputParameters(params, checkpoint, tree, aln);
74-
74+
7575
if (params.include_pre_mutations)
7676
{
7777
outWarning("Ignore predefined mutations in the input tree since it is not supported in simulations to mimick an input alignment.");
@@ -343,7 +343,7 @@ std::vector<std::pair<std::string,std::string>> readMutations(const std::string&
343343
{
344344
// init a vector of node mutations
345345
std::vector<std::pair<std::string,std::string>> node_mutations;
346-
346+
347347
// open file, read line by line
348348
try
349349
{
@@ -352,13 +352,13 @@ std::vector<std::pair<std::string,std::string>> readMutations(const std::string&
352352
outError("File not found: " + mutation_file);
353353
std::ifstream file(mutation_file);
354354
std::string line;
355-
355+
356356
// read line by line
357357
while (std::getline(file, line))
358358
{
359359
// ignore empty line
360360
if (!line.length()) continue;
361-
361+
362362
// remove spaces at the begining of the line
363363
auto pos = line.find_first_not_of(" ");
364364
// find the first non-space character
@@ -371,7 +371,7 @@ std::vector<std::pair<std::string,std::string>> readMutations(const std::string&
371371
// if not found -> all characters are spaces -> invalid
372372
else
373373
outError("Invalid format '" + line + "'. Expected format should be <node_name><spaces><list_of_mutations>");
374-
374+
375375
// remove spaces at the ending of the line
376376
pos = line.find_last_not_of(" ");
377377
// find the last non-space character
@@ -384,27 +384,27 @@ std::vector<std::pair<std::string,std::string>> readMutations(const std::string&
384384
// if not found -> all characters are spaces -> invalid
385385
else
386386
outError("Invalid format '" + line + "'. Expected format should be <node_name><spaces><list_of_mutations>");
387-
387+
388388
// validate the input format <node_name><spaces><list_of_mutations>
389389
if (line.length() < 5)
390390
outError("Invalid format '" + line + "'. Expected format should be <node_name><spaces><list_of_mutations>");
391-
391+
392392
// replace \t by a space
393393
line = regex_replace(line, std::regex("\t"), " ");
394-
394+
395395
// get the node name
396396
std::string node_name = "";
397397
pos = line.find(" ");
398398
if (pos != std::string::npos)
399399
{
400400
node_name = line.substr(0, pos);
401-
401+
402402
// convert node_name to uppercase
403403
transform(node_name.begin(), node_name.end(), node_name.begin(), ::toupper);
404404
}
405405
else
406406
outError("Invalid format '" + line + "'. Expected format should be <node_name><spaces><list_of_mutations>");
407-
407+
408408
// get mutation list at that node
409409
std::string mutation_str = "";
410410
// find the first non-space character after the position
@@ -415,19 +415,19 @@ std::vector<std::pair<std::string,std::string>> readMutations(const std::string&
415415
mutation_str = line.substr(pos, line.length() - pos);
416416
else
417417
outError("Invalid format '" + line + "'. Expected format should be <node_name><spaces><list_of_mutations>");
418-
418+
419419
// record the mutations at that node
420420
node_mutations.push_back(std::pair<std::string,std::string>(node_name, mutation_str));
421421
}
422-
422+
423423
// close file
424424
file.close();
425425
}
426426
catch(std::exception e)
427427
{
428428
outError("File not found or invalid format " + mutation_file);
429429
}
430-
430+
431431
// return result
432432
return node_mutations;
433433
}
@@ -566,10 +566,10 @@ void retrieveAncestralSequenceFromInputFile(AliSimulator *super_alisimulator, ve
566566
aln->extractSequences(aln_filepath, sequence_type, sequences, nseq, nsite);
567567
StrVector seq_names = aln->getSeqNames();
568568
delete[] aln_filepath;
569-
569+
570570
// delete aln
571571
delete aln;
572-
572+
573573
string sequence_str = "";
574574
for (int i = 0; i < seq_names.size(); i++)
575575
if (!sequence_name.compare(seq_names[i]))
@@ -587,7 +587,7 @@ void retrieveAncestralSequenceFromInputFile(AliSimulator *super_alisimulator, ve
587587
outWarning("Sequence length is now set equally to the length of ancestral sequence.");
588588
super_alisimulator->refreshExpectedNumSites();
589589
}
590-
590+
591591
// get Max number of states
592592
int max_num_states = src_tree->aln->getMaxNumStates();
593593

@@ -643,16 +643,16 @@ void getLockedSites(Node* const node, Node* const dad, std::vector<bool>* const
643643
{
644644
// sequence length
645645
const int seq_length = site_locked_vec->size();
646-
646+
647647
// parse a list of mutations
648648
Substitutions pre_mutations = Substitutions(atb_it->second, aln, seq_length);
649-
649+
650650
// mark those sites locked
651651
for (auto mut_it = pre_mutations.begin(); mut_it != pre_mutations.end(); ++mut_it)
652652
{
653653
// extract position
654654
const int pos = mut_it->getPosition();
655-
655+
656656
// vailidate position
657657
if (pos >= seq_length)
658658
{
@@ -663,7 +663,7 @@ void getLockedSites(Node* const node, Node* const dad, std::vector<bool>* const
663663
site_locked_vec->at(pos) = true;
664664
}
665665
}
666-
666+
667667
// browse 1-step deeper to the neighbor node
668668
getLockedSites((*it)->node, node, site_locked_vec, aln);
669669
}
@@ -677,7 +677,7 @@ void createNodeMapping(std::map<std::string, std::pair<Node*, Node*>>& node_mapp
677677
std::string node_name = node->name;
678678
// convert to uppercase
679679
transform(node_name.begin(), node_name.end(), node_name.begin(), ::toupper);
680-
680+
681681
node_mapping.insert(std::pair<std::string, std::pair<Node*, Node*>>(node_name, std::pair<Node*, Node*>(dad, node)));
682682
}
683683
// process its neighbors/children
@@ -692,11 +692,11 @@ void addMutations2Tree(const std::vector<std::pair<std::string, std::string>>& n
692692
{
693693
// validate input
694694
ASSERT(tree && tree->root);
695-
695+
696696
// create a mapping between each node name and a pair of pointers <dad_node, node>
697697
std::map<std::string, std::pair<Node*, Node*>> node_mapping;
698698
createNodeMapping(node_mapping, tree->root, NULL);
699-
699+
700700
// browse the list of node_mutations to add mutations of each node to the corresponding node in the tree
701701
for (const std::pair<std::string, std::string>& mutations : node_mutations)
702702
{
@@ -707,7 +707,7 @@ void addMutations2Tree(const std::vector<std::pair<std::string, std::string>>& n
707707
// Extract the corresponding pair of nodes
708708
Node* dad = (it->second).first;
709709
Node* node = (it->second).second;
710-
710+
711711
// add attribute (mutations,<mutations_list> to the corresponding branch
712712
dad->findNeighbor(node)->putAttr(MTree::ANTT_MUT, "{" + mutations.second + "}");
713713
node->findNeighbor(dad)->putAttr(MTree::ANTT_MUT, "{" + mutations.second + "}");
@@ -751,7 +751,7 @@ void generateMultipleAlignmentsFromSingleTree(AliSimulator *super_alisimulator,
751751
cout << " - Number of threads for MPI processes: " << super_alisimulator->params->num_threads * MPIHelper::getInstance().getNumProcesses() << endl;
752752
}
753753
#endif
754-
754+
755755
// reset number of OpenMP threads to 1 in simulations with Indels
756756
if (super_alisimulator->params->num_threads != 1 && super_alisimulator->params->alisim_insertion_ratio + super_alisimulator->params->alisim_deletion_ratio > 0)
757757
{
@@ -841,28 +841,28 @@ void generateMultipleAlignmentsFromSingleTree(AliSimulator *super_alisimulator,
841841
else
842842
{
843843
ASSERT(super_alisimulator->tree && super_alisimulator->tree->root && super_alisimulator->tree->aln);
844-
844+
845845
// show info
846846
std::cout << "Predefined mutations detected" << std::endl;
847-
847+
848848
// load predefined mutations from a file (if specified)
849849
if (super_alisimulator->params->mutation_file.length())
850850
{
851851
std::vector<std::pair<std::string, std::string>> node_mutations = readMutations(super_alisimulator->params->mutation_file);
852-
852+
853853
// add mutations to tree
854854
if (node_mutations.size())
855855
addMutations2Tree(node_mutations, super_alisimulator->tree);
856856
}
857-
857+
858858
// init site_locked_vec
859859
site_locked_vec = new std::vector<bool>(super_alisimulator->expected_num_sites, false);
860-
860+
861861
// browse the tree to mark all locked sites
862862
getLockedSites(super_alisimulator->tree->root, NULL, site_locked_vec, super_alisimulator->tree->aln);
863863
}
864864
}
865-
865+
866866
// the output format of the simulated alignment
867867
InputType actual_output_format = super_alisimulator->params->aln_output_format;
868868
vector<SeqType> seqtypes;
@@ -1109,7 +1109,7 @@ void generateMultipleAlignmentsFromSingleTree(AliSimulator *super_alisimulator,
11091109
// output full tree (with internal node names) if outputting internal sequences
11101110
if (super_alisimulator->params->alisim_write_internal_sequences)
11111111
outputTreeWithInternalNames(super_alisimulator);
1112-
1112+
11131113
// delete site_locked_vec (if necessary)
11141114
if (site_locked_vec)
11151115
delete site_locked_vec;
@@ -1217,12 +1217,12 @@ void generatePartitionAlignmentFromSingleSimulator(AliSimulator *&alisimulator,
12171217
if ((!rate_name.empty()) || is_mixture_model)
12181218
{
12191219
delete tmp_alisimulator;
1220-
1220+
12211221
// bug fixes: avoid accessing to deallocated pointer
12221222
if (alisimulator->params->alisim_insertion_ratio + alisimulator->params->alisim_deletion_ratio > 0)
12231223
alisimulator->first_insertion = nullptr;
12241224
}
1225-
1225+
12261226
}
12271227

12281228
/**
@@ -1265,15 +1265,15 @@ void writeSequencesToFile(string file_path, Alignment *aln, int sequence_length,
12651265
// get the position to write output
12661266
start_pos = first_line.length();
12671267
}
1268-
1268+
12691269
if (!alisimulator->params->do_compression)
12701270
start_pos = out->tellp();
1271-
1271+
12721272
// for Windows only, the line break is \r\n instead of only \n
12731273
#if defined WIN32 || defined _WIN32 || defined __WIN32__ || defined WIN64
12741274
++start_pos;
12751275
#endif
1276-
1276+
12771277
uint64_t output_line_length = seq_length_times_num_sites_per_state + 1 + alisimulator->max_length_taxa_name + (alisimulator->params->aln_output_format == IN_FASTA ? 1 : 0);
12781278

12791279
// for Windows only, the line break is \r\n instead of only \n

0 commit comments

Comments
 (0)