summaryrefslogtreecommitdiffstats
path: root/academic/vCAPS_coevolution/02_caps_sort_input.patch
blob: 917bca7cabead6ced00aaa5c80628fd0d8449563 (plain)
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
diff -pruN old/caps.cpp new/caps.cpp
--- old/caps.cpp	2022-01-20 09:30:24.409886691 +0200
+++ new/caps.cpp	2022-01-20 09:39:10.669845265 +0200
@@ -1,4 +1,5 @@
 #include<iostream>
+#include <algorithm>
 #include<fstream>
 #include"BCFasta.h"
 #include"file_manip.h"
@@ -15,7 +16,7 @@
 #include<sys/time.h>
 #include<iomanip>
 #include <bits/stdc++.h> 
-
+#include <vector> 
 
 
 #include <Seq/SequenceApplicationTools.h>
@@ -69,6 +70,10 @@
 const gsl_rng_type * T;
 gsl_rng *r;
 
+// make sure filenames are sorted!
+// https://stackoverflow.com/a/34757557
+bool compareFunction (std::string a, std::string b) {return a<b;} 
+
 vector<double> totaltempnew;
 double alphathresh = 0;
 int main(int argc, char *argv[]){
@@ -189,6 +194,8 @@ int main(int argc, char *argv[]){
 
 	vector<string> files;
 	files = Folder_to_vector(mystring.c_str());
+	// make sure filenames are sorted!
+	std::sort(files.begin(),files.end(),compareFunction);
 
 	Fasta_vector file;
 	file.ref_num=0;