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 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608
|
/*
* clustersplitcommand.cpp
* Mothur
*
* Created by westcott on 5/19/10.
* Copyright 2010 Schloss Lab. All rights reserved.
*
*/
#include "clustersplitcommand.h"
#include "systemcommand.h"
#include "sensspeccommand.h"
#include "mcc.hpp"
#include "sensitivity.hpp"
#include "specificity.hpp"
#include "fdr.hpp"
#include "npv.hpp"
#include "ppv.hpp"
#include "f1score.hpp"
#include "tp.hpp"
#include "fp.hpp"
#include "fpfn.hpp"
#include "tptn.hpp"
#include "tn.hpp"
#include "fn.hpp"
#include "accuracy.hpp"
//**********************************************************************************************************************
vector<string> ClusterSplitCommand::setParameters(){
try {
CommandParameter pfile("file", "InputTypes", "", "", "PhylipColumnFasta", "PhylipColumnFasta", "none","",false,false,true); parameters.push_back(pfile);
CommandParameter ptaxonomy("taxonomy", "InputTypes", "", "", "none", "none", "FastaTaxName","",false,false,true); parameters.push_back(ptaxonomy);
CommandParameter pfasta("fasta", "InputTypes", "", "", "PhylipColumnFasta", "PhylipColumnFasta", "FastaTaxName","list",false,false,true); parameters.push_back(pfasta);
CommandParameter pname("name", "InputTypes", "", "", "NameCount", "none", "ColumnName-FastaTaxName","rabund-sabund",false,false,true); parameters.push_back(pname);
CommandParameter pcount("count", "InputTypes", "", "", "NameCount", "none", "","",false,false,true); parameters.push_back(pcount);
CommandParameter ptaxlevel("taxlevel", "Number", "", "3", "", "", "","",false,false,true); parameters.push_back(ptaxlevel);
CommandParameter pshowabund("showabund", "Boolean", "", "T", "", "", "","",false,false); parameters.push_back(pshowabund);
CommandParameter prunspenspec("runsensspec", "Boolean", "", "T", "", "", "","",false,false); parameters.push_back(prunspenspec);
CommandParameter pcluster("cluster", "Boolean", "", "T", "", "", "","",false,false); parameters.push_back(pcluster);
CommandParameter ptiming("timing", "Boolean", "", "F", "", "", "","",false,false); parameters.push_back(ptiming);
CommandParameter pprocessors("processors", "Number", "", "1", "", "", "","",false,false,true); parameters.push_back(pprocessors);
CommandParameter pcutoff("cutoff", "Number", "", "0.03", "", "", "","",false,false,true); parameters.push_back(pcutoff);
CommandParameter pmetriccutoff("delta", "Number", "", "0.0001", "", "", "","",false,false,true); parameters.push_back(pmetriccutoff);
CommandParameter piters("iters", "Number", "", "100", "", "", "","",false,false,true); parameters.push_back(piters);
CommandParameter pinitialize("initialize", "Multiple", "oneotu-singleton", "singleton", "", "", "","",false,false,true); parameters.push_back(pinitialize);
CommandParameter pprecision("precision", "Number", "", "100", "", "", "","",false,false); parameters.push_back(pprecision);
CommandParameter pmethod("method", "Multiple", "furthest-nearest-average-weighted-agc-dgc-opti", "opti", "", "", "","",false,false,true); parameters.push_back(pmethod);
CommandParameter pmetric("metric", "Multiple", "mcc-sens-spec-tptn-fpfn-tp-tn-fp-fn-f1score-accuracy-ppv-npv-fdr", "mcc", "", "", "","",false,false,true); parameters.push_back(pmetric);
CommandParameter pdist("dist", "Boolean", "", "F", "", "", "","",false,false); parameters.push_back(pdist);
CommandParameter pislist("islist", "Boolean", "", "F", "", "", "","",false,false); parameters.push_back(pislist);
CommandParameter pclassic("classic", "Boolean", "", "F", "", "", "","",false,false); parameters.push_back(pclassic);
CommandParameter pvsearchlocation("vsearch", "String", "", "", "", "", "","",false,false); parameters.push_back(pvsearchlocation);
CommandParameter pseed("seed", "Number", "", "0", "", "", "","",false,false); parameters.push_back(pseed);
CommandParameter pinputdir("inputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(pinputdir);
CommandParameter poutputdir("outputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(poutputdir);
abort = false; calledHelp = false;
vector<string> tempOutNames;
outputTypes["list"] = tempOutNames;
outputTypes["rabund"] = tempOutNames;
outputTypes["sabund"] = tempOutNames;
outputTypes["column"] = tempOutNames;
outputTypes["name"] = tempOutNames;
outputTypes["file"] = tempOutNames;
outputTypes["sensspec"] = tempOutNames;
vector<string> myArray;
for (int i = 0; i < parameters.size(); i++) { myArray.push_back(parameters[i].name); }
return myArray;
}
catch(exception& e) {
m->errorOut(e, "ClusterSplitCommand", "setParameters");
exit(1);
}
}
//**********************************************************************************************************************
string ClusterSplitCommand::getHelpString(){
try {
string helpString = "";
helpString += "The cluster.split command parameter options are file, fasta, name, count, cutoff, precision, method, taxonomy, taxlevel, showabund, timing, cluster, iters, delta, initialize, dist, processors, runsensspec. Fasta or file are required.\n";
helpString += "The cluster.split command splits your files by classification using a fasta file to generate distance matrices for each taxonomic group. \n";
helpString += "The file option allows you to enter your file containing your list of column and names/count files as well as the singleton file. This file is mothur generated, when you run cluster.split() with the cluster=f parameter. This can be helpful when you have a large dataset that you may be able to use all your processors for the splitting step, but have to reduce them for the cluster step due to RAM constraints. For example: cluster.split(fasta=yourFasta, taxonomy=yourTax, count=yourCount, taxlevel=3, cluster=f, processors=8) then cluster.split(file=yourFile, processors=4). This allows your to maximize your processors during the splitting step. Also, if you are unsure if the cluster step will have RAM issue with multiple processors, you can avoid running the first part of the command multiple times.\n";
helpString += "The fasta parameter allows you to enter your aligned fasta file. \n";
helpString += "The name parameter allows you to enter your name file. \n";
helpString += "The count parameter allows you to enter your count file.\n";
helpString += "The taxonomy parameter allows you to enter the taxonomy file for your sequences. This is required unless you are running the command with the file option. \n";
helpString += "The cluster parameter allows you to indicate whether you want to run the clustering or just split the dataset into taxanomic matrices, default=t";
helpString += "The dist parameter allows you to indicate whether you want a column formatted distance matrix outputted along with the list file. Default=F.";
helpString += "The cutoff parameter allow you to set the distance you want to cluster to, default is 0.03. \n";
helpString += "The precision parameter allows you specify the precision of the precision of the distances outputted, default=100, meaning 2 decimal places. \n";
helpString += "The iters parameter allow you to set the maxiters for the opticluster method. \n";
helpString += "The metric parameter allows to select the metric in the opticluster method. Options are Matthews correlation coefficient (mcc), sensitivity (sens), specificity (spec), true positives + true negatives (tptn), false positives + false negatives (fpfn), true positives (tp), true negative (tn), false positive (fp), false negative (fn), f1score (f1score), accuracy (accuracy), positive predictive value (ppv), negative predictive value (npv), false discovery rate (fdr). Default=mcc.\n";
helpString += "The delta parameter allows to set the stable value for the metric in the opticluster method. Default=0.0001\n";
helpString += "The initialize parameter allows to select the initial randomization for the opticluster method. Options are singleton, meaning each sequence is randomly assigned to its own OTU, or oneotu meaning all sequences are assigned to one otu. Default=singleton.\n";
helpString += "The runsensspec parameter allows to run the sens.spec command on the completed list file. Default=true.\n";
helpString += "The method parameter allows you to enter your clustering mothod. Options are furthest, nearest, average, weighted, agc, dgc and opti. Default=opti. The agc and dgc methods require a fasta file.";
helpString += "The taxlevel parameter allows you to specify the taxonomy level you want to use to split the dataset, default=3.\n";
helpString += "The classic parameter allows you to indicate that you want to run your files with cluster.classic. Default=f.\n";
helpString += "The processors parameter allows you to specify the number of processors to use. The default is all available.\n";
helpString += "The vsearch parameter allows you to specify the name and location of your vsearch executable if using agc or dgc clustering methods. By default mothur will look in your path, mothur's executable and mothur tools locations. You can set the vsearch location as follows, vsearch=/usr/bin/vsearch.\n";
helpString += "The cluster.split command should be in the following format: \n";
helpString += "cluster.split(fasta=yourFastaFile, count=yourCountFile, method=yourMethod, cutoff=yourCutoff, taxonomy=yourTaxonomyfile, taxlevel=yourtaxlevel) \n";
return helpString;
}
catch(exception& e) {
m->errorOut(e, "ClusterSplitCommand", "getHelpString");
exit(1);
}
}
//**********************************************************************************************************************
string ClusterSplitCommand::getOutputPattern(string type) {
try {
string pattern = "";
if (type == "list") { pattern = "[filename],[clustertag],list-[filename],[clustertag],[tag2],list"; }
else if (type == "rabund") { pattern = "[filename],[clustertag],rabund"; }
else if (type == "sabund") { pattern = "[filename],[clustertag],sabund"; }
else if (type == "sensspec") { pattern = "[filename],[clustertag],sensspec"; }
else if (type == "column") { pattern = "[filename],dist"; }
else if (type == "file") { pattern = "[filename],file"; }
else { m->mothurOut("[ERROR]: No definition for type " + type + " output pattern.\n"); m->setControl_pressed(true); }
return pattern;
}
catch(exception& e) {
m->errorOut(e, "ClusterSplitCommand", "getOutputPattern");
exit(1);
}
}
//**********************************************************************************************************************
string ClusterSplitCommand::getCommonQuestions(){
try {
vector<string> questions, issues, qanswers, ianswers, howtos, hanswers;
string issue = "Cluster.split crashes after merging individual list files. What do I do?"; issues.push_back(issue);
string ianswer = "\tAfter merging the split list files, mothur runs the sens.spec command on the entire dataset. The entire dataset's distance matrix may be too large to fit in memory, which causes the crash. You can skip this step by setting the runsensspec parameter to false. Skipping the sens.spec analysis does not effect the OTU assignment, and you can run the sens.spec analysis separately using the sens.spec command. \n"; ianswers.push_back(ianswer);
issue = "Cluster.split crashes while reading the split distance matrices. What should I do?"; issues.push_back(issue);
ianswer = "\tThe command is crashing because the distance matrices are too large to fit into memory. Why do I have such a large distance matrix? This is most often caused by poor overlap of your reads. When reads have poor overlap, it greatly increases your error rate. Also, sequences that should cluster together don't because the errors appear to be genetic differences when in fact they are not. The quality of the data you are processing can not be overstressed. Error filled reads produce error filled results. To take a step back, if you look through our MiSeq SOP, you’ll see that we go to great pains to only work with the unique sequences to limit the number of sequences we have to align, screen for chimeras, classify, etc. We all know that 20 million reads will never make it through the pipeline without setting your computer on fire. Returning to the question at hand, you can imagine that if the reads do not fully overlap then any error in the 5’ end of the first read will be uncorrected by the 3’ end of the second read. If we assume for now that the errors are random, then every error will generate a new unique sequence. Granted, this happens less than 1% of the time, but multiply that by 20 million reads at whatever length you choose and you’ve got a big number. Viola, a bunch of unique reads and a ginormous distance matrix. \n"; ianswers.push_back(ianswer);
string howto = "How do I cluster my sequences into OTUs at distance 0.03?"; howtos.push_back(howto);
string hanswer = "\tBy default the cluster.split command will use the opti method to cluster to 0.03. To find OTUs at a different distance set the cutoff parameter. ie. cutoff=0.01 will assemble OTUs for distance 0.01.\n"; hanswers.push_back(hanswer);
string commonQuestions = util.getFormattedHelp(questions, qanswers, issues, ianswers, howtos, hanswers);
return commonQuestions;
}
catch(exception& e) {
m->errorOut(e, "ClusterSplitCommand", "getCommonQuestions");
exit(1);
}
}
//**********************************************************************************************************************
//This function checks to make sure the cluster command has no errors and then clusters based on the method chosen.
ClusterSplitCommand::ClusterSplitCommand(string option) : Command() {
try{
format = "";
//allow user to run help
if(option == "help") { help(); abort = true; calledHelp = true; }
else if(option == "citation") { citation(); abort = true; calledHelp = true;}
else if(option == "category") { abort = true; calledHelp = true; }
else {
OptionParser parser(option, setParameters());
map<string,string> parameters = parser.getParameters();
ValidParameters validParameter;
//check for required parameters
file = validParameter.validFile(parameters, "file");
if (file == "not open") { file = ""; abort = true; }
else if (file == "not found") { file = ""; }
else { distfile = file; type = ""; }
namefile = validParameter.validFile(parameters, "name");
if (namefile == "not open") { abort = true; namefile = "";}
else if (namefile == "not found") { namefile = ""; }
else { current->setNameFile(namefile); type = "name"; }
countfile = validParameter.validFile(parameters, "count");
if (countfile == "not open") { abort = true; countfile = "";}
else if (countfile == "not found") { countfile = ""; }
else { current->setCountFile(countfile); type = "count"; }
fastafile = validParameter.validFile(parameters, "fasta");
if (fastafile == "not open") { abort = true; }
else if (fastafile == "not found") { fastafile = ""; }
else { distfile = fastafile; current->setFastaFile(fastafile); }
taxFile = validParameter.validFile(parameters, "taxonomy");
if (taxFile == "not open") { taxFile = ""; abort = true; }
else if (taxFile == "not found") { taxFile = ""; }
else { current->setTaxonomyFile(taxFile); }
if ((fastafile == "") && (file == "")) {
fastafile = current->getFastaFile();
if (fastafile != "") { m->mothurOut("Using " + fastafile + " as input file for the fasta parameter.\n"); }
else {
m->mothurOut("[ERROR]: No valid current files. When executing a cluster.split command you must enter a file file or fastafile.\n"); abort = true;
}
}
else if ((fastafile != "") && (file != "")) { m->mothurOut("[ERROR]: When executing a cluster.split command you must enter ONLY ONE of the following: file or fasta.\n"); abort = true; }
if ((countfile != "") && (namefile != "")) { m->mothurOut("[ERROR]: When executing a cluster.split command you must enter ONLY ONE of the following: count or name.\n"); abort = true; }
if (file != "") {
if ((namefile == "") && (countfile == "")) {
m->mothurOut("\n[WARNING]: When using the file option, it is recommended you include the name or count file. Doing so will ensure the OTUs are printed by OTU size reflecting the redundant reads, instead of just the unique reads.\n");
}
}
if (fastafile != "") {
if (taxFile == "") {
taxFile = current->getTaxonomyFile();
if (taxFile != "") { m->mothurOut("Using " + taxFile + " as input file for the taxonomy parameter.\n"); }
else {
m->mothurOut("[ERROR]: You need to provide a taxonomy file if you are if you are using a fasta file to generate the split.\n");
abort = true;
}
}
if ((namefile == "") && (countfile == "")) {
namefile = current->getNameFile();
if (namefile != "") { m->mothurOut("Using " + namefile + " as input file for the name parameter.\n"); type = "name"; }
else {
countfile = current->getCountFile();
if (countfile != "") { m->mothurOut("Using " + countfile + " as input file for the count parameter.\n"); type = "count"; }
else { m->mothurOut("[ERROR]: You need to provide a namefile or countfile.\n"); abort = true;
}
}
}
}
string temp;
temp = validParameter.valid(parameters, "precision");
if (temp == "not found") { temp = "100"; }
//saves precision legnth for formatting below
length = temp.length();
util.mothurConvert(temp, precision);
temp = validParameter.valid(parameters, "processors"); if (temp == "not found"){ temp = current->getProcessors(); }
processors = current->setProcessors(temp);
temp = validParameter.valid(parameters, "classic"); if (temp == "not found") { temp = "F"; }
classic = util.isTrue(temp);
temp = validParameter.valid(parameters, "runsensspec"); if (temp == "not found") { temp = "T"; }
runsensSpec = util.isTrue(temp);
temp = validParameter.valid(parameters, "taxlevel"); if (temp == "not found") { temp = "3"; }
util.mothurConvert(temp, taxLevelCutoff);
temp = validParameter.valid(parameters, "iters"); if (temp == "not found") { temp = "100"; }
util.mothurConvert(temp, maxIters);
temp = validParameter.valid(parameters, "delta"); if (temp == "not found") { temp = "0.0001"; }
util.mothurConvert(temp, stableMetric);
metricName = validParameter.valid(parameters, "metric"); if (metricName == "not found") { metricName = "mcc"; }
if ((metricName == "mcc") || (metricName == "sens") || (metricName == "spec") || (metricName == "tptn") || (metricName == "tp") || (metricName == "tn") || (metricName == "fp") || (metricName == "fn") || (metricName == "f1score") || (metricName == "accuracy") || (metricName == "ppv") || (metricName == "npv") || (metricName == "fdr") || (metricName == "fpfn") ){ }
else { m->mothurOut("[ERROR]: Not a valid metric. Valid metrics are mcc, sens, spec, tp, tn, fp, fn, tptn, fpfn, f1score, accuracy, ppv, npv, fdr.\n"); abort = true; }
initialize = validParameter.valid(parameters, "initialize"); if (initialize == "not found") { initialize = "singleton"; }
if ((initialize == "singleton") || (initialize == "oneotu")){ }
else { m->mothurOut("[ERROR]: Not a valid initialization. Valid initializations are singleton and oneotu.\n"); abort = true; }
method = validParameter.valid(parameters, "method"); if (method == "not found") { method = "opti"; }
vector<string> versionOutputs;
bool foundTool = false;
string programName = "vsearch"; programName += EXECUTABLE_EXT;
vsearchLocation = validParameter.validPath(parameters, "vsearch");
if (vsearchLocation == "not found") {
vsearchLocation = "";
if ((method == "agc") || (method == "dgc")) {
foundTool = util.findTool(programName, vsearchLocation, versionOutputs, current->getLocations());
}
}
else {
if ((method == "agc") || (method == "dgc")) {
//test to make sure vsearch exists
ifstream in;
vsearchLocation = util.getFullPathName(vsearchLocation);
bool ableToOpen = util.openInputFile(vsearchLocation, in, "no error"); in.close();
if(!ableToOpen) {
m->mothurOut(vsearchLocation + " file does not exist or cannot be opened, ignoring.\n"); vsearchLocation = "";
programName = util.getSimpleName(vsearchLocation); vsearchLocation = "";
foundTool = util.findTool(programName, vsearchLocation, versionOutputs, current->getLocations());
}
}
}
if ((method == "furthest") || (method == "nearest") || (method == "average") || (method == "weighted") || (method == "agc") || (method == "dgc") || (method == "opti")) { }
else { m->mothurOut("[ERROR]: Not a valid clustering method. Valid clustering algorithms are furthest, nearest, average, weighted, agc, dgc and opti.\n"); abort = true; }
if ((method == "agc") || (method == "dgc")) {
if (fastafile == "") { m->mothurOut("[ERROR]: You must provide a fasta file when using the agc or dgc clustering methods, aborting\n."); abort = true;}
if (classic) { m->mothurOut("[ERROR]: You cannot use cluster.classic with the agc or dgc clustering methods, aborting\n."); abort = true; }
if (!foundTool) { abort = true; }
}
cutoffNotSet = false;
temp = validParameter.valid(parameters, "cutoff");
if (temp == "not found") { cutoffNotSet = true; if ((method == "opti") || (method == "agc") || (method == "dgc")) { temp = "0.03"; }else { temp = "0.15"; } }
util.mothurConvert(temp, cutoff);
temp = validParameter.valid(parameters, "showabund");
if (temp == "not found") { temp = "T"; }
showabund = util.isTrue(temp);
temp = validParameter.valid(parameters, "cluster"); if (temp == "not found") { temp = "T"; }
runCluster = util.isTrue(temp);
temp = validParameter.valid(parameters, "islist"); if (temp == "not found") { temp = "F"; }
isList = util.isTrue(temp);
temp = validParameter.valid(parameters, "dist"); if (temp == "not found") { temp = "F"; }
makeDist = util.isTrue(temp);
if (method == "opti") { makeDist = runsensSpec; }
if (classic && makeDist) { m->mothurOut("[ERROR]: You cannot use the dist parameter with the classic parameter. Mothur will ignore the dist parameter.\n"); makeDist = false; }
timing = validParameter.valid(parameters, "timing");
if (timing == "not found") { timing = "F"; }
}
}
catch(exception& e) {
m->errorOut(e, "ClusterSplitCommand", "ClusterSplitCommand");
exit(1);
}
}
//**********************************************************************************************************************
int ClusterSplitCommand::execute(){
try {
if (abort) { if (calledHelp) { return 0; } return 2; }
time_t estart;
vector<string> listFileNames;
vector< map<string, string> > distName;
set<string> labels;
string singletonName = "";
double saveCutoff = cutoff;
if (file != "") {
deleteFiles = false; estart = time(nullptr);
singletonName = readFile(distName);
if (isList) {
//set list file as new current listfile
string currentName = "";
itTypes = outputTypes.find("list");
if (itTypes != outputTypes.end()) {
if ((itTypes->second).size() != 0) { currentName = (itTypes->second)[0]; current->setListFile(currentName); }
}
m->mothurOut("\nOutput File Names: \n");
for (int i = 0; i < outputNames.size(); i++) { m->mothurOut(outputNames[i] + "\n"); } m->mothurOutEndLine();
return 0;
}
}else {
//splitting
estart = time(nullptr); bool usingVsearchToCLuster = false;
if ((method == "agc") || (method == "dgc")) { usingVsearchToCLuster = true; if (cutoffNotSet) { m->mothurOut("\nYou did not set a cutoff, using 0.03.\n"); cutoff = 0.03; } }
m->mothurOut("Splitting the file...\n");
current->setMothurCalling(true);
//split matrix into non-overlapping groups
SplitMatrix* split = new SplitMatrix(fastafile, namefile, countfile, taxFile, taxLevelCutoff, cutoff, processors, classic, outputdir, usingVsearchToCLuster);
if (fastafile != "") { current->setFastaFile(fastafile); }
if (m->getControl_pressed()) { delete split; return 0; }
singletonName = split->getSingletonNames();
distName = split->getDistanceFiles(); //returns map of distance files -> namefile sorted by distance file size
delete split;
current->setMothurCalling(false);
if (m->getDebug()) { m->mothurOut("[DEBUG]: distName.size() = " + toString(distName.size()) + ".\n"); }
m->mothurOut("It took " + toString(time(nullptr) - estart) + " seconds to split the distance file.\n");
//output a merged distance file
if (makeDist) { createMergedDistanceFile(distName); }
if (m->getControl_pressed()) { return 0; }
estart = time(nullptr);
if (!runCluster) {
string filename = printFile(singletonName, distName);
m->mothurOutEndLine();
m->mothurOut("Output File Names:\n\n"); m->mothurOut(filename); m->mothurOutEndLine();
for (int i = 0; i < distName.size(); i++) { m->mothurOut(distName[i].begin()->first); m->mothurOutEndLine(); m->mothurOut(distName[i].begin()->second); m->mothurOutEndLine(); }
m->mothurOutEndLine();
return 0;
}
deleteFiles = true;
}
//****************** break up files between processes and cluster each file set ******************************//
listFileNames = createProcesses(distName, labels);
if (deleteFiles) {
//delete the temp files now that we are done
for (int i = 0; i < distName.size(); i++) {
string thisNamefile = distName[i].begin()->second;
string thisDistFile = distName[i].begin()->first;
util.mothurRemove(thisNamefile);
util.mothurRemove(thisDistFile);
}
}
if (m->getControl_pressed()) { for (int i = 0; i < listFileNames.size(); i++) { util.mothurRemove(listFileNames[i]); } return 0; }
if (!util.isEqual(saveCutoff, cutoff)) { m->mothurOut("\nCutoff was " + toString(saveCutoff) + " changed cutoff to " + toString(cutoff)); m->mothurOutEndLine(); }
m->mothurOut("It took " + toString(time(nullptr) - estart) + " seconds to cluster\n");
//****************** merge list file and create rabund and sabund files ******************************//
estart = time(nullptr);
m->mothurOut("Merging the clustered files...\n");
ListVector* listSingle;
map<double, int> labelBins = completeListFile(listFileNames, singletonName, labels, listSingle); //returns map of label to numBins
if (m->getControl_pressed()) { if (listSingle != nullptr) { delete listSingle; } for (int i = 0; i < outputNames.size(); i++) { util.mothurRemove(outputNames[i]); } return 0; }
mergeLists(listFileNames, labelBins, listSingle);
if (m->getControl_pressed()) { for (int i = 0; i < outputNames.size(); i++) { util.mothurRemove(outputNames[i]); } return 0; }
//delete after all are complete incase a crash happens
if (!deleteFiles) { for (int i = 0; i < distName.size(); i++) { util.mothurRemove(distName[i].begin()->first); util.mothurRemove(distName[i].begin()->second); } }
m->mothurOut("It took " + toString(time(nullptr) - estart) + " seconds to merge.\n");
if ((method == "opti") && (runsensSpec)) { runSensSpec(); }
if (m->getControl_pressed()) { for (int i = 0; i < outputNames.size(); i++) { util.mothurRemove(outputNames[i]); } return 0; }
//set list file as new current listfile
string currentName = "";
itTypes = outputTypes.find("list");
if (itTypes != outputTypes.end()) {
if ((itTypes->second).size() != 0) { currentName = (itTypes->second)[0]; current->setListFile(currentName); }
}
//set rabund file as new current rabundfile
itTypes = outputTypes.find("rabund");
if (itTypes != outputTypes.end()) { if ((itTypes->second).size() != 0) { currentName = (itTypes->second)[0]; current->setRabundFile(currentName); } }
//set sabund file as new current sabundfile
itTypes = outputTypes.find("sabund");
if (itTypes != outputTypes.end()) { if ((itTypes->second).size() != 0) { currentName = (itTypes->second)[0]; current->setSabundFile(currentName); } }
//set sabund file as new current sabundfile
itTypes = outputTypes.find("column");
if (itTypes != outputTypes.end()) { if ((itTypes->second).size() != 0) { currentName = (itTypes->second)[0]; current->setColumnFile(currentName); } }
m->mothurOut("\nOutput File Names: \n");
for (int i = 0; i < outputNames.size(); i++) { m->mothurOut(outputNames[i] +"\n"); } m->mothurOutEndLine();
return 0;
}
catch(exception& e) {
m->errorOut(e, "ClusterSplitCommand", "execute");
exit(1);
}
}
//**********************************************************************************************************************
map<double, int> ClusterSplitCommand::completeListFile(vector<string> listNames, string singleton, set<string>& userLabels, ListVector*& listSingle){
try {
map<double, int> labelBin;
vector<double> orderFloat;
int numSingleBins;
//read in singletons
if (singleton != "none") {
listSingle = new ListVector();
if (type == "count") {
CountTable ct; ct.readTable(singleton, false, false);
vector<string> singletonSeqNames = ct.getNamesOfSeqs();
for (int i = 0; i < singletonSeqNames.size(); i++) { listSingle->push_back(singletonSeqNames[i]); }
}else if (type == "name") {
map<string, string> singletonSeqNames; util.readNames(singleton, singletonSeqNames);
for (map<string, string>::iterator it = singletonSeqNames.begin(); it != singletonSeqNames.end(); it++) { listSingle->push_back(it->second); }
}
util.mothurRemove(singleton);
numSingleBins = listSingle->getNumBins();
}else{ listSingle = nullptr; numSingleBins = 0; }
//go through users set and make them floats so we can sort them
for(set<string>::iterator it = userLabels.begin(); it != userLabels.end(); ++it) {
double temp = -10.0;
if ((*it != "unique") && (convertTestFloat(*it, temp) )) { util.mothurConvert(*it, temp); }
else if (*it == "unique") { temp = -1.0; }
if ((temp < cutoff) || util.isEqual(cutoff, temp)) {
orderFloat.push_back(temp);
labelBin[temp] = numSingleBins; //initialize numbins
}
}
//sort order
sort(orderFloat.begin(), orderFloat.end());
userLabels.clear();
//get the list info from each file
for (int k = 0; k < listNames.size(); k++) {
if (m->getControl_pressed()) {
if (listSingle != nullptr) { delete listSingle; listSingle = nullptr; util.mothurRemove(singleton); }
for (int i = 0; i < listNames.size(); i++) { util.mothurRemove(listNames[i]); }
return labelBin;
}
InputData* input = new InputData(listNames[k], "list", nullVector);
ListVector* list = input->getListVector();
string lastLabel = list->getLabel();
string filledInList = listNames[k] + "filledInTemp";
ofstream outFilled;
util.openOutputFile(filledInList, outFilled);
bool printHeaders = true;
//for each label needed
for(int l = 0; l < orderFloat.size(); l++){
string thisLabel;
if (util.isEqual(orderFloat[l],-1)) { thisLabel = "unique"; }
else { thisLabel = toString(orderFloat[l], length-1); }
//this file has reached the end
if (list == nullptr) {
list = input->getListVector(lastLabel, true);
}else{ //do you have the distance, or do you need to fill in
float labelFloat;
if (list->getLabel() == "unique") { labelFloat = -1.0; }
else { convert(list->getLabel(), labelFloat); }
//check for missing labels
if (labelFloat > orderFloat[l]) { //you are missing the label, get the next smallest one
//if its bigger get last label, otherwise keep it
delete list;
list = input->getListVector(lastLabel, true); //get last list vector to use, you actually want to move back in the file
}
lastLabel = list->getLabel();
}
//print to new file
list->setLabel(thisLabel);
list->setPrintedLabels(printHeaders);
list->print(outFilled, true); printHeaders = false;
//update labelBin
labelBin[orderFloat[l]] += list->getNumBins();
delete list;
list = input->getListVector();
}
if (list != nullptr) { delete list; }
delete input;
outFilled.close();
util.mothurRemove(listNames[k]);
rename(filledInList.c_str(), listNames[k].c_str());
}
return labelBin;
}
catch(exception& e) {
m->errorOut(e, "ClusterSplitCommand", "completeListFile");
exit(1);
}
}
//**********************************************************************************************************************
int ClusterSplitCommand::mergeLists(vector<string> listNames, map<double, int> userLabels, ListVector* listSingle){
try {
if (outputdir == "") { outputdir += util.hasPath(distfile); }
fileroot = outputdir + util.getRootName(util.getSimpleName(distfile));
map<string, string> variables;
variables["[filename]"] = fileroot;
variables["[clustertag]"] = tag;
string sabundFileName = getOutputFileName("sabund", variables);
string rabundFileName = getOutputFileName("rabund", variables);
string listFileName = getOutputFileName("list", variables);
map<string, int> counts;
ofstream outList, outRabund, outSabund;
if (countfile == "") {
util.openOutputFile(sabundFileName, outSabund);
util.openOutputFile(rabundFileName, outRabund);
outputNames.push_back(sabundFileName); outputTypes["sabund"].push_back(sabundFileName);
outputNames.push_back(rabundFileName); outputTypes["rabund"].push_back(rabundFileName);
}else {
CountTable ct;
ct.readTable(countfile, false, false);
counts = ct.getNameMap();
}
util.openOutputFile(listFileName, outList);
outputNames.push_back(listFileName); outputTypes["list"].push_back(listFileName);
bool printHeaders = true;
//for each label needed
for(map<double, int>::iterator itLabel = userLabels.begin(); itLabel != userLabels.end(); itLabel++) {
string thisLabel;
if (util.isEqual(itLabel->first,-1)) { thisLabel = "unique"; }
else { thisLabel = toString(itLabel->first, length-1); }
//outList << thisLabel << '\t' << itLabel->second << '\t';
RAbundVector* rabund = nullptr;
ListVector completeList;
completeList.setLabel(thisLabel);
if (countfile == "") {
rabund = new RAbundVector();
rabund->setLabel(thisLabel);
}
//add in singletons
if (listSingle != nullptr) {
for (int j = 0; j < listSingle->getNumBins(); j++) {
//outList << listSingle->get(j) << '\t';
completeList.push_back(listSingle->get(j));
if (countfile == "") { rabund->push_back(util.getNumNames(listSingle->get(j))); }
}
}
//get the list info from each file
for (int k = 0; k < listNames.size(); k++) {
if (m->getControl_pressed()) { if (listSingle != nullptr) { delete listSingle; } for (int i = 0; i < listNames.size(); i++) { util.mothurRemove(listNames[i]); } if (rabund != nullptr) { delete rabund; } return 0; }
InputData* input = new InputData(listNames[k], "list", nullVector);
ListVector* list = input->getListVector(thisLabel);
//this file has reached the end
if (list == nullptr) { m->mothurOut("Error merging listvectors in file " + listNames[k]); m->mothurOutEndLine(); }
else {
for (int j = 0; j < list->getNumBins(); j++) {
completeList.push_back(list->get(j));
if (countfile == "") { rabund->push_back(util.getNumNames(list->get(j))); }
}
delete list;
}
delete input;
}
if (countfile == "") {
SAbundVector sabund = rabund->getSAbundVector();
sabund.print(outSabund);
rabund->print(outRabund);
}
completeList.setPrintedLabels(printHeaders);
if (countfile != "") { completeList.print(outList, counts); printHeaders = false; }
else { completeList.print(outList); printHeaders = false; }
if (rabund != nullptr) { delete rabund; }
}
outList.close();
if (countfile == "") {
outRabund.close();
outSabund.close();
}
if (listSingle != nullptr) { delete listSingle; }
for (int i = 0; i < listNames.size(); i++) { util.mothurRemove(listNames[i]); }
return 0;
}
catch(exception& e) {
m->errorOut(e, "ClusterSplitCommand", "mergeLists");
exit(1);
}
}
/**************************************************************************************************/
struct clusterData {
MothurOut* m;
Utils util;
int count, precision, length, maxIters; //numSingletons,
bool showabund, classic, useName, useCount, deleteFiles, cutoffNotSet;
double cutoff, stableMetric;
ofstream outList, outRabund, outSabund;
string tag, method, vsearchLocation, metricName, initialize, outputDir, type;
vector< map<string, string> > distNames;
set<string> labels;
vector<string> listFileNames;
clusterData(){}
clusterData(bool showab, bool cla, bool df, vector< map<string, string> > dN, bool cns, double cu, int prec, int len, string meth, string opd, string vl, string ty) {
showabund = showab;
distNames = dN;
cutoff = cu;
classic = cla;
method = meth;
precision = prec;
length = len;
outputDir = opd;
vsearchLocation = vl;
deleteFiles = df;
cutoffNotSet = cns;
m = MothurOut::getInstance();
count = 0;
type = ty;
useName = false;
useCount = false;
//numSingletons = 0;
}
void setOptiOptions(string metn, double stabMet, string init, int mxi ) {
metricName = metn;
stableMetric = stabMet;
maxIters = mxi;
initialize = init;
}
void setNamesCount(string cnf) {
useName = false;
useCount = false;
if (type == "name") { useName = true; }
if (type == "count") { useCount = true; }
}
};
//**********************************************************************************************************************
int createRabund(CountTable*& ct, ListVector*& list, RAbundVector*& rabund, clusterData* params){
try {
rabund->setLabel(list->getLabel());
for(int i = 0; i < list->getNumBins(); i++) {
if (params->m->getControl_pressed()) { break; }
vector<string> binNames;
string bin = list->get(i);
params->util.splitAtComma(bin, binNames);
int total = 0;
for (int j = 0; j < binNames.size(); j++) { total += ct->getNumSeqs(binNames[j]); }
rabund->push_back(total);
}
return 0;
}
catch(exception& e) {
params->m->errorOut(e, "ClusterSplitCommand", "createRabund");
exit(1);
}
}
//**********************************************************************************************************************
string clusterClassicFile(string thisDistFile, string thisNamefile, double& smallestCutoff, clusterData* params){
try {
string listFileName = "";
ListVector* list = nullptr;
ListVector oldList;
RAbundVector* rabund = nullptr;
params->m->mothurOut("\nReading " + thisDistFile + "\n");
//reads phylip file storing data in 2D vector, also fills list and rabund
bool sim = false;
ClusterClassic cluster(params->cutoff, params->method, sim);
NameAssignment* nameMap = nullptr;
CountTable* ct = nullptr;
if(params->useName){
nameMap = new NameAssignment(thisNamefile);
nameMap->readMap();
cluster.readPhylipFile(thisDistFile, nameMap);
}else if (params->useCount) {
ct = new CountTable();
ct->readTable(thisNamefile, false, false);
cluster.readPhylipFile(thisDistFile, ct);
}
params->tag = cluster.getTag();
if (params->m->getControl_pressed()) { if(params->useName){ delete nameMap; }
else if (params->useCount) { delete ct; } return listFileName; }
list = cluster.getListVector();
rabund = cluster.getRAbundVector();
string thisOutputDir = params->outputDir;
if (params->outputDir == "") { thisOutputDir += params->util.hasPath(thisDistFile); }
string fileroot = thisOutputDir + params->util.getRootName(params->util.getSimpleName(thisDistFile));
listFileName = fileroot+ params->tag + ".list";
ofstream listFile;
params->util.openOutputFile(fileroot+ params->tag + ".list", listFile);
float previousDist = 0.00000;
float rndPreviousDist = 0.00000;
bool printHeaders = true;
oldList = *list;
params->m->mothurOut("\nClustering " + thisDistFile + "\n");
while ((cluster.getSmallDist() < params->cutoff) && (cluster.getNSeqs() > 1)){
if (params->m->getControl_pressed()) { delete list; delete rabund; listFile.close(); if(params->useName){ delete nameMap; }
else if (params->useCount) { delete ct; } return listFileName; }
cluster.update(params->cutoff);
float dist = cluster.getSmallDist();
float rndDist = params->util.ceilDist(dist, params->precision);
if(previousDist <= 0.0000 && !params->util.isEqual(dist, previousDist)){
oldList.setLabel("unique");
oldList.setPrintedLabels(printHeaders);
oldList.print(listFile); printHeaders = false;
if (params->labels.count("unique") == 0) { params->labels.insert("unique"); }
}
else if(!params->util.isEqual(rndDist, rndPreviousDist)){
oldList.setLabel(toString(rndPreviousDist, params->length-1));
oldList.setPrintedLabels(printHeaders);
oldList.print(listFile); printHeaders = false;
if (params->labels.count(toString(rndPreviousDist, params->length-1)) == 0) { params->labels.insert(toString(rndPreviousDist, params->length-1)); }
}
previousDist = dist;
rndPreviousDist = rndDist;
oldList = *list;
}
if(previousDist <= 0.0000){
oldList.setLabel("unique");
oldList.setPrintedLabels(printHeaders);
oldList.print(listFile); printHeaders = false;
if (params->labels.count("unique") == 0) { params->labels.insert("unique"); }
}
else if(rndPreviousDist<params->cutoff){
oldList.setLabel(toString(rndPreviousDist, params->length-1));
oldList.setPrintedLabels(printHeaders);
oldList.print(listFile); printHeaders = false;
if (params->labels.count(toString(rndPreviousDist, params->length-1)) == 0) { params->labels.insert(toString(rndPreviousDist, params->length-1)); }
}
listFile.close();
delete list; delete rabund;
if(params->useName) { delete nameMap; }
else if (params->useCount) { delete ct; }
if (params->deleteFiles) {
params->util.mothurRemove(thisDistFile);
params->util.mothurRemove(thisNamefile);
}
return listFileName;
}
catch(exception& e) {
params->m->errorOut(e, "ClusterSplitCommand", "clusterClassicFile");
exit(1);
}
}
//**********************************************************************************************************************
string runOptiCluster(string thisDistFile, string thisNamefile, double& smallestCutoff, clusterData* params){
try {
if (params->cutoffNotSet) { params->m->mothurOut("\nYou did not set a cutoff, using 0.03.\n"); params->cutoff = 0.03; }
string nameOrCount = params->type;
OptiMatrix matrix(thisDistFile, thisNamefile, nameOrCount, "column", params->cutoff, false);
ClusterMetric* metric = nullptr;
if (params->metricName == "mcc") { metric = new MCC(); }
else if (params->metricName == "sens") { metric = new Sensitivity(); }
else if (params->metricName == "spec") { metric = new Specificity(); }
else if (params->metricName == "tptn") { metric = new TPTN(); }
else if (params->metricName == "tp") { metric = new TP(); }
else if (params->metricName == "tn") { metric = new TN(); }
else if (params->metricName == "fp") { metric = new FP(); }
else if (params->metricName == "fn") { metric = new FN(); }
else if (params->metricName == "f1score") { metric = new F1Score(); }
else if (params->metricName == "accuracy") { metric = new Accuracy(); }
else if (params->metricName == "ppv") { metric = new PPV(); }
else if (params->metricName == "npv") { metric = new NPV(); }
else if (params->metricName == "fdr") { metric = new FDR(); }
else if (params->metricName == "fpfn") { metric = new FPFN(); }
OptiCluster cluster(&matrix, metric, 0);
params->tag = cluster.getTag();
params->m->mothurOut("\nClustering " + thisDistFile + "\n");
string thisOutputDir = params->outputDir;
if (params->outputDir == "") { thisOutputDir += params->util.hasPath(thisDistFile); }
string fileroot = thisOutputDir + params->util.getRootName(params->util.getSimpleName(thisDistFile));
string listFileName = fileroot+ params->tag + ".list";
int iters = 0;
double listVectorMetric = 0; //worst state
double delta = 1;
cluster.initialize(listVectorMetric, true, params->initialize);
while ((delta > params->stableMetric) && (iters < params->maxIters)) {
if (params->m->getControl_pressed()) { if (params->deleteFiles) { params->util.mothurRemove(thisDistFile); params->util.mothurRemove(thisNamefile); } return listFileName; }
double oldMetric = listVectorMetric;
cluster.update(listVectorMetric);
delta = abs(oldMetric - listVectorMetric);
iters++;
}
if (params->m->getControl_pressed()) { delete metric; metric = nullptr; return 0; }
ListVector* list = cluster.getList();
list->setLabel(toString(smallestCutoff));
//params->cutoff = params->util.ceilDist(params->cutoff, params->precision);
params->labels.insert(toString(smallestCutoff));
ofstream listFile;
params->util.openOutputFile(listFileName, listFile);
list->print(listFile);
listFile.close();
if (params->deleteFiles) {
params->util.mothurRemove(thisDistFile);
params->util.mothurRemove(thisNamefile);
}
double tp, tn, fp, fn;
params->m->mothurOut("\ntp\ttn\tfp\tfn\tsensitivity\tspecificity\tppv\tnpv\tfdr\taccuracy\tmcc\tf1score\n");
vector<double> results = cluster.getStats(tp, tn, fp, fn);
params->m->mothurOut(toString(tp) + "\t" + toString(tn) + "\t" + toString(fp) + "\t" + toString(fn) + "\t");
for (int i = 0; i < results.size(); i++) { params->m->mothurOut(toString(results[i]) + "\t"); }
params->m->mothurOut("\n\n");
return listFileName;
}
catch(exception& e) {
params->m->errorOut(e, "ClusterSplitCommand", "runOptiCluster");
exit(1);
}
}
//**********************************************************************************************************************
int vsearchDriver(string inputFile, string ucClusteredFile, string logfile, double cutoff, clusterData* params){
try {
//vsearch --maxaccepts 16 --usersort --id 0.97 --minseqlength 30 --wordlength 8 --uc $ROOT.clustered.uc --cluster_smallmem $ROOT.sorted.fna --maxrejects 64 --strand both --log $ROOT.clustered.log --sizeorder
ucClusteredFile = params->util.getFullPathName(ucClusteredFile);
inputFile = params->util.getFullPathName(inputFile);
logfile = params->util.getFullPathName(logfile);
//to allow for spaces in the path
ucClusteredFile = "\"" + ucClusteredFile + "\"";
inputFile = "\"" + inputFile + "\"";
logfile = "\"" + logfile + "\"";
vector<char*> cPara;
string vsearchCommand = params->vsearchLocation;
vsearchCommand = "\"" + vsearchCommand + "\" ";
vector<char*> vsearchParameters;
vsearchParameters.push_back(params->util.mothurConvert(vsearchCommand));
//--maxaccepts=16
vsearchParameters.push_back(params->util.mothurConvert("--maxaccepts=16"));
//--threads=1
string processorsString = "--threads=1";
vsearchParameters.push_back(params->util.mothurConvert(processorsString));
//--usersort
vsearchParameters.push_back(params->util.mothurConvert("--usersort"));
//--id=0.97
cutoff = abs(1.0 - cutoff); string cutoffString = toString(cutoff);
if (cutoffString.length() > 4) { cutoffString = cutoffString.substr(0, 4); }
else if (cutoffString.length() < 4) { for (int i = cutoffString.length(); i < 4; i++) { cutoffString += "0"; } }
cutoffString = "--id=" + cutoffString;
vsearchParameters.push_back(params->util.mothurConvert(cutoffString));
//--minseqlength=30
vsearchParameters.push_back(params->util.mothurConvert("--minseqlength=30"));
//--wordlength=8
vsearchParameters.push_back(params->util.mothurConvert("--wordlength=8"));
//--uc=$ROOT.clustered.uc
string tempIn = "--uc=" + ucClusteredFile;
vsearchParameters.push_back(params->util.mothurConvert(tempIn));
//--cluster_smallmem $ROOT.sorted.fna
string tempSorted = "--cluster_smallmem=" + inputFile;
vsearchParameters.push_back(params->util.mothurConvert(tempSorted));
//--maxrejects=64
vsearchParameters.push_back(params->util.mothurConvert("--maxrejects=64"));
//--strand=both
vsearchParameters.push_back(params->util.mothurConvert("--strand=both"));
//--log=$ROOT.clustered.log
string tempLog = "--log=" + logfile;
vsearchParameters.push_back(params->util.mothurConvert(tempLog));
if (params->method == "agc") { //--sizeorder
vsearchParameters.push_back(params->util.mothurConvert("--sizeorder"));
}
if (params->m->getDebug()) { params->m->mothurOut("[DEBUG]: "); for(int i = 0; i < vsearchParameters.size(); i++) { params->m->mothurOut(toString(vsearchParameters[i]) + "\t"); } params->m->mothurOut("\n"); }
string commandString = "";
for (int i = 0; i < vsearchParameters.size(); i++) { commandString += toString(vsearchParameters[i]) + " "; }
#if defined NON_WINDOWS
#else
commandString = "\"" + commandString + "\"";
#endif
if (params->m->getDebug()) { params->m->mothurOut("[DEBUG]: vsearch cluster command = " + commandString + ".\n"); }
system(commandString.c_str());
//free memory
for(int i = 0; i < vsearchParameters.size(); i++) { delete vsearchParameters[i]; }
//remove "" from filenames
ucClusteredFile = ucClusteredFile.substr(1, ucClusteredFile.length()-2);
inputFile = inputFile.substr(1, inputFile.length()-2);
logfile = logfile.substr(1, logfile.length()-2);
return 0;
}
catch(exception& e) {
params->m->errorOut(e, "ClusterSplitCommand", "vsearchDriver");
exit(1);
}
}
//**********************************************************************************************************************
string runVsearchCluster(string thisDistFile, string thisNamefile, double& smallestCutoff, clusterData* params){
try {
params->m->mothurOut("\nClustering " + thisDistFile + "\n");
string vsearchFastafile = ""; VsearchFileParser* vParse;
if (params->useName) { vParse = new VsearchFileParser(thisDistFile, thisNamefile, "name"); }
else if (params->useCount) { vParse = new VsearchFileParser(thisDistFile, thisNamefile, "count"); }
else { params->m->mothurOut("[ERROR]: Opps, should never get here. ClusterSplitCommand::runVsearchCluster() \n"); params->m->setControl_pressed(true); return ""; }
if (params->m->getControl_pressed()) { delete vParse; return ""; }
vsearchFastafile = vParse->getVsearchFile();
if (params->cutoff > 1.0) { params->m->mothurOut("You did not set a cutoff, using 0.03.\n"); params->cutoff = 0.03; }
//Run vsearch
string ucVsearchFile = params->util.getSimpleName(vsearchFastafile) + ".clustered.uc";
string logfile = params->util.getSimpleName(vsearchFastafile) + ".clustered.log";
vsearchDriver(vsearchFastafile, ucVsearchFile, logfile, smallestCutoff, params);
if (params->m->getControl_pressed()) { params->util.mothurRemove(ucVsearchFile); params->util.mothurRemove(logfile); params->util.mothurRemove(vsearchFastafile); return ""; }
string thisOutputDir = params->outputDir;
if (params->outputDir == "") { thisOutputDir += params->util.hasPath(thisDistFile); }
params->tag = params->method;
string listFileName = thisOutputDir + params->util.getRootName(params->util.getSimpleName(thisDistFile)) + params->tag + ".list";
//Convert outputted *.uc file into a list file
map<string, int> counts;
ListVector list = vParse->createListFile(ucVsearchFile, vParse->getNumBins(logfile), toString(params->cutoff), counts);
ofstream out;
params->util.openOutputFile(listFileName, out);
list.DataVector::printHeaders(out);
if (params->useCount) { list.print(out, counts); }
else { list.print(out); } delete vParse;
//remove temp files
params->util.mothurRemove(ucVsearchFile); params->util.mothurRemove(logfile); params->util.mothurRemove(vsearchFastafile);
if (params->deleteFiles) {
params->util.mothurRemove(thisDistFile);
params->util.mothurRemove(thisNamefile);
}
params->labels.insert(toString(params->cutoff));
return listFileName;
}
catch(exception& e) {
params->m->errorOut(e, "ClusterSplitCommand", "runVsearchCluster");
exit(1);
}
}
//**********************************************************************************************************************
string clusterFile(string thisDistFile, string thisNamefile, double& smallestCutoff, clusterData* params){
try {
string listFileName = "";
if ((params->method == "agc") || (params->method == "dgc")) { listFileName = runVsearchCluster(thisDistFile, thisNamefile, smallestCutoff, params); }
else if (params->method == "opti") { listFileName = runOptiCluster(thisDistFile, thisNamefile, smallestCutoff, params); }
else {
Cluster* cluster = nullptr;
SparseDistanceMatrix* matrix = nullptr;
ListVector* list = nullptr;
ListVector oldList;
RAbundVector* rabund = nullptr;
if (params->m->getControl_pressed()) { return listFileName; }
params->m->mothurOut("\nReading " + thisDistFile + "\n");
ReadMatrix* read = new ReadColumnMatrix(thisDistFile);
read->setCutoff(params->cutoff);
NameAssignment* nameMap = nullptr;
CountTable* ct = nullptr;
if(params->useName){
nameMap = new NameAssignment(thisNamefile);
nameMap->readMap();
read->read(nameMap);
}else if (params->useCount) {
ct = new CountTable();
ct->readTable(thisNamefile, false, false);
read->read(ct);
}else { read->read(nameMap); }
list = read->getListVector();
matrix = read->getDMatrix();
if(params->useCount) {
rabund = new RAbundVector();
createRabund(ct, list, rabund, params); //creates an rabund that includes the counts for the unique list
delete ct;
}else { rabund = new RAbundVector(list->getRAbundVector()); }
delete read; read = nullptr;
if (params->useName) { delete nameMap; nameMap = nullptr; }
params->m->mothurOut("\nClustering " + thisDistFile + "\n");
//create cluster
float adjust = -1.0;
if (params->method == "furthest") { cluster = new CompleteLinkage(rabund, list, matrix, params->cutoff, params->method, adjust); }
else if(params->method == "nearest"){ cluster = new SingleLinkage(rabund, list, matrix, params->cutoff, params->method, adjust); }
else if(params->method == "average"){ cluster = new AverageLinkage(rabund, list, matrix, params->cutoff, params->method, adjust); }
params->tag = cluster->getTag();
string thisOutputDir = params->outputDir;
if (params->outputDir == "") { thisOutputDir += params->util.hasPath(thisDistFile); }
string fileroot = thisOutputDir + params->util.getRootName(params->util.getSimpleName(thisDistFile));
listFileName = fileroot+ params->tag + ".list";
ofstream listFile;
params->util.openOutputFile(listFileName, listFile);
float previousDist = 0.00000;
float rndPreviousDist = 0.00000;
bool printHeaders = true;
oldList = *list;
double saveCutoff = params->cutoff;
while (matrix->getSmallDist() < params->cutoff && matrix->getNNodes() > 0){
if (params->m->getControl_pressed()) { //clean up
delete matrix; delete list; delete cluster; delete rabund;
listFile.close();
params->util.mothurRemove(listFileName);
return listFileName;
}
cluster->update(saveCutoff);
float dist = matrix->getSmallDist();
float rndDist = params->util.ceilDist(dist, params->precision);
if(previousDist <= 0.0000 && !params->util.isEqual(dist, previousDist)){
oldList.setLabel("unique");
oldList.setPrintedLabels(printHeaders);
oldList.print(listFile); printHeaders = false;
if (params->labels.count("unique") == 0) { params->labels.insert("unique"); }
}
else if(!params->util.isEqual(rndDist, rndPreviousDist)){
oldList.setPrintedLabels(printHeaders);
oldList.setLabel(toString(rndPreviousDist, params->length-1));
oldList.setPrintedLabels(printHeaders);
oldList.print(listFile); printHeaders = false;
if (params->labels.count(toString(rndPreviousDist, params->length-1)) == 0) { params->labels.insert(toString(rndPreviousDist, params->length-1)); }
}
previousDist = dist;
rndPreviousDist = rndDist;
oldList = *list;
}
if(previousDist <= 0.0000){
oldList.setLabel("unique");
oldList.setPrintedLabels(printHeaders);
oldList.print(listFile); printHeaders = false;
if (params->labels.count("unique") == 0) { params->labels.insert("unique"); }
}
else if(rndPreviousDist<params->cutoff){
oldList.setLabel(toString(rndPreviousDist, params->length-1));
oldList.setPrintedLabels(printHeaders);
oldList.print(listFile); printHeaders = false;
if (params->labels.count(toString(rndPreviousDist, params->length-1)) == 0) { params->labels.insert(toString(rndPreviousDist, params->length-1)); }
}
delete matrix; delete list; delete cluster; delete rabund;
matrix = nullptr; list = nullptr; cluster = nullptr; rabund = nullptr;
listFile.close();
if (params->m->getControl_pressed()) { //clean up
params->util.mothurRemove(listFileName);
return listFileName;
}
if (params->deleteFiles) {
params->util.mothurRemove(thisDistFile);
params->util.mothurRemove(thisNamefile);
}
if (!params->util.isEqual(saveCutoff, params->cutoff)) {
saveCutoff = params->util.ceilDist(saveCutoff, params->precision);
params->m->mothurOut("Cutoff was " + toString(params->cutoff) + " changed cutoff to " + toString(saveCutoff) + "\n");
}
if (saveCutoff < smallestCutoff) { smallestCutoff = saveCutoff; }
}
return listFileName;
}
catch(exception& e) {
params->m->errorOut(e, "ClusterSplitCommand", "clusterFile");
exit(1);
}
}
//**********************************************************************************************************************
void cluster(clusterData* params){
try {
vector<string> listFileNames;
double smallestCutoff = params->cutoff;
//cluster each distance file
for (int i = 0; i < params->distNames.size(); i++) {
string thisNamefile = params->distNames[i].begin()->second;
string thisDistFile = params->distNames[i].begin()->first;
params->setNamesCount(thisNamefile);
string listFileName = "";
if (params->classic) { listFileName = clusterClassicFile(thisDistFile, thisNamefile, smallestCutoff, params); }
else { listFileName = clusterFile(thisDistFile, thisNamefile, smallestCutoff, params); }
if (params->m->getControl_pressed()) { //clean up
for (int i = 0; i < listFileNames.size(); i++) { params->util.mothurRemove(listFileNames[i]); }
params->listFileNames.clear(); break;
}
params->listFileNames.push_back(listFileName);
}
params->cutoff = smallestCutoff;
}
catch(exception& e) {
params->m->errorOut(e, "ClusterSplitCommand", "cluster");
exit(1);
}
}
//**********************************************************************************************************************
void printData(ListVector* oldList, clusterData* params){
try {
string label = oldList->getLabel();
RAbundVector oldRAbund = oldList->getRAbundVector();
oldRAbund.setLabel(label);
if (params->showabund) {
oldRAbund.getSAbundVector().print(cout);
}
oldRAbund.print(params->outRabund);
oldRAbund.getSAbundVector().print(params->outSabund);
oldList->print(params->outList, true);
}
catch(exception& e) {
params->m->errorOut(e, "ClusterSplitCommand", "printData");
exit(1);
}
}
//**********************************************************************************************************************
vector<string> ClusterSplitCommand::createProcesses(vector< map<string, string> > distName, set<string>& labels){
try {
//sanity check
if (processors > distName.size()) { processors = distName.size(); }
deleteFiles = false; //so if we need to recalc the processors the files are still there
vector<string> listFiles;
vector < vector < map<string, string> > > dividedNames; //distNames[1] = vector of filenames for process 1...
dividedNames.resize(processors);
//for each file group figure out which process will complete it
//want to divide the load intelligently so the big files are spread between processes
for (int i = 0; i < distName.size(); i++) {
int processToAssign = (i+1) % processors;
if (processToAssign == 0) { processToAssign = processors; }
dividedNames[(processToAssign-1)].push_back(distName[i]);
if ((processToAssign-1) == 1) { m->mothurOut(distName[i].begin()->first + "\n"); }
}
//now lets reverse the order of ever other process, so we balance big files running with little ones
for (int i = 0; i < processors; i++) {
int remainder = ((i+1) % processors);
if (remainder) { reverse(dividedNames[i].begin(), dividedNames[i].end()); }
}
if (m->getControl_pressed()) { return listFiles; }
//create array of worker threads
vector<std::thread*> workerThreads;
vector<clusterData*> data;
//Lauch worker threads
for (int i = 0; i < processors-1; i++) {
clusterData* dataBundle = new clusterData(showabund, classic, deleteFiles, dividedNames[i+1], cutoffNotSet, cutoff, precision, length, method, outputdir, vsearchLocation, type);
dataBundle->setOptiOptions(metricName, stableMetric, initialize, maxIters);
data.push_back(dataBundle);
workerThreads.push_back(new std::thread(cluster, dataBundle));
}
clusterData* dataBundle = new clusterData(showabund, classic, deleteFiles, dividedNames[0], cutoffNotSet, cutoff, precision, length, method, outputdir, vsearchLocation, type);
dataBundle->setOptiOptions(metricName, stableMetric, initialize, maxIters);
cluster(dataBundle);
listFiles = dataBundle->listFileNames;
tag = dataBundle->tag;
cutoff = dataBundle->cutoff;
labels = dataBundle->labels;
for (int i = 0; i < processors-1; i++) {
workerThreads[i]->join();
listFiles.insert(listFiles.end(), data[i]->listFileNames.begin(), data[i]->listFileNames.end());
labels.insert(data[i]->labels.begin(), data[i]->labels.end());
if (data[i]->cutoff < cutoff) { cutoff = data[i]->cutoff; }
delete data[i];
delete workerThreads[i];
}
delete dataBundle;
deleteFiles = true;
return listFiles;
}
catch(exception& e) {
m->errorOut(e, "ClusterSplitCommand", "createProcesses");
exit(1);
}
}
//**********************************************************************************************************************
int ClusterSplitCommand::createMergedDistanceFile(vector< map<string, string> > distNames) {
try{
string thisOutputDir = outputdir;
if (outputdir == "") { thisOutputDir = util.hasPath(fastafile); }
map<string, string> variables;
variables["[filename]"] = thisOutputDir + util.getRootName(util.getSimpleName(fastafile));
string outputFileName = getOutputFileName("column", variables);
util.mothurRemove(outputFileName);
for (int i = 0; i < distNames.size(); i++) {
if (m->getControl_pressed()) { return 0; }
string thisDistFile = distNames[i].begin()->first;
util.appendFiles(thisDistFile, outputFileName);
}
outputTypes["column"].push_back(outputFileName); outputNames.push_back(outputFileName);
return 0;
}
catch(exception& e) {
m->errorOut(e, "ClusterSplitCommand", "createMergedDistanceFile");
exit(1);
}
}
//**********************************************************************************************************************
int ClusterSplitCommand::runSensSpec() {
try{
string listFile = "";
itTypes = outputTypes.find("list");
if (itTypes != outputTypes.end()) {
if ((itTypes->second).size() != 0) { listFile = (itTypes->second)[0]; }
}
string columnFile = "";
if (makeDist) {
itTypes = outputTypes.find("column");
if (itTypes != outputTypes.end()) {
if ((itTypes->second).size() != 0) { columnFile = (itTypes->second)[0]; }
}
}
string inputString = "cutoff=" + toString(cutoff) + ", list=" + listFile;
if (columnFile != "") { inputString += ", column=" + columnFile; }
else { m->mothurOut("[WARNING]: Cannot run sens.spec analysis without a column file, skipping."); return 0; }
if (namefile != "") { inputString += ", name=" + namefile; }
else if (countfile != "") { inputString += ", count=" + countfile; }
else { m->mothurOut("[WARNING]: Cannot run sens.spec analysis without a name or count file, skipping."); return 0; }
m->mothurOut("/******************************************/\n");
m->mothurOut("Running command: sens.spec(" + inputString + ")\n");
current->setMothurCalling(true);
Command* sensspecCommand = new SensSpecCommand(inputString);
sensspecCommand->execute();
map<string, vector<string> > filenames = sensspecCommand->getOutputFiles();
delete sensspecCommand;
current->setMothurCalling(false);
string outputFileName = filenames["sensspec"][0];
outputTypes["sensspec"].push_back(outputFileName); outputNames.push_back(outputFileName);
m->mothurOut("/******************************************/\n");
m->mothurOut("Done.\n\n\n");
ifstream in; util.openInputFile(outputFileName, in);
while(!in.eof()){
if (m->getControl_pressed()) { break; }
m->mothurOut(util.getline(in)+"\n"); gobble(in);
}
in.close();
return 0;
}
catch(exception& e) {
m->errorOut(e, "ClusterSplitCommand", "runSensSpec");
exit(1);
}
}
//**********************************************************************************************************************
string ClusterSplitCommand::printFile(string singleton, vector< map<string, string> >& distName){
try {
ofstream out;
map<string, string> variables;
string thisOutputDir = outputdir;
if (outputdir == "") { thisOutputDir = util.hasPath(distfile); }
variables["[filename]"] = thisOutputDir + util.getRootName(util.getSimpleName(distfile));
string outputFileName = getOutputFileName("file", variables);
util.openOutputFile(outputFileName, out);
outputTypes["file"].push_back(outputFileName); outputNames.push_back(outputFileName);
current->setFileFile(outputFileName);
out << singleton << endl;
if (namefile != "") { out << "name" << endl; }
else if (countfile != "") { out << "count" << endl; }
else { out << "unknown" << endl; }
for (int i = 0; i < distName.size(); i++) { out << distName[i].begin()->first << '\t' << distName[i].begin()->second << endl; }
out.close();
return outputFileName;
}
catch(exception& e) {
m->errorOut(e, "ClusterSplitCommand", "printFile");
exit(1);
}
}
//**********************************************************************************************************************
string ClusterSplitCommand::readFile(vector< map<string, string> >& distName){
try {
string singleton, thiscolumn, thisname;
ifstream in; util.openInputFile(file, in);
in >> singleton; gobble(in);
string path = util.hasPath(singleton);
if (path == "") { singleton = inputDir + singleton; }
in >> type; gobble(in);
if (type == "name") { }
else if (type == "count") { }
else { m->mothurOut("[ERROR]: unknown file type. Are the files in column 2 of the file name files or count files? Please change unknown to name or count.\n"); m->setControl_pressed(true); }
if (isList) {
vector<string> listFileNames;
string thisListFileName = "";
set<string> listLabels;
while(!in.eof()) {
if (m->getControl_pressed()) { break; }
in >> thisListFileName; gobble(in);
string path = util.hasPath(thisListFileName);
if (path == "") { thisListFileName = inputDir + thisListFileName; }
getLabels(thisListFileName, listLabels);
listFileNames.push_back(thisListFileName);
}
ListVector* listSingle;
map<double, int> labelBins = completeListFile(listFileNames, singleton, listLabels, listSingle);
mergeLists(listFileNames, labelBins, listSingle);
}else {
while(!in.eof()) {
if (m->getControl_pressed()) { break; }
in >> thiscolumn; gobble(in);
in >> thisname; gobble(in);
map<string, string> temp;
temp[thiscolumn] = thisname;
distName.push_back(temp);
}
}
in.close();
return singleton;
}
catch(exception& e) {
m->errorOut(e, "ClusterSplitCommand", "readFile");
exit(1);
}
}
//**********************************************************************************************************************
int ClusterSplitCommand::getLabels(string file, set<string>& listLabels){
try {
ifstream in; util.openInputFile(file, in);
//read headers
util.getline(in); gobble(in);
string label;
while(!in.eof()) {
if (m->getControl_pressed()) { break; }
in >> label; util.getline(in); gobble(in);
listLabels.insert(label);
}
in.close();
return 0;
}
catch(exception& e) {
m->errorOut(e, "ClusterSplitCommand", "getLabels");
exit(1);
}
}
//**********************************************************************************************************************
|