dab89c1682e091dfa3780ce95359ebea9f6b7d52 braney Thu May 18 09:49:17 2017 -0700 add licensing info to optimalLeaf library diff --git src/optimalLeaf/bestArr.cc src/optimalLeaf/bestArr.cc index 8110031..86fa4bb 100644 --- src/optimalLeaf/bestArr.cc +++ src/optimalLeaf/bestArr.cc @@ -1,230 +1,236 @@ +/* This code provided by Ziv Bar-Joseph with the explicit understanding that + * no licensing is required for it to be used in the UCSC Genome Browser + * as long as reference is made to this paper: + * https://www.ncbi.nlm.nih.gov/pubmed/12801867 + */ + //----------------------------------------------------------- // Bestarrange.cc // Builds an hierarchical clustering tree, and finds its optimal // leaf ordering. The program gets as an input an expression // file (see README) and generates four files as output. // The first two (for an input file named foo.txt, these are called fooIn.GTR // and fooIn.CDT) are the hierarchical clustering reuslts. The other two // files (foo.CDT and foo.GTR) are the optima leaf ordering results. // Both these results can be viewed using Michael Eisen's TreeView // software. //---------------------------------------------------------- #include #include #include using namespace std; #include #include #include "general.hh" #include "Tree.hh" #include "SimMat.hh" extern "C" { #include "optimalLeaf.h" } const int BUFSIZE = 100; Tree *createTree(int num,float **m,char *str); char *nameFile(char *name,char *e,char *m); void copyFile(char *from, char *to); #ifdef NOTNOW main(int argc,char** argv) { int i,len = strlen(argv[1]); char *fullName = new char[len+6]; strcpy(fullName,argv[1]); strcat(fullName,".txt"); fullName[len+5] = '\0'; int newD = descLen; // initial maximum length of description int newO = orfLen; // initial maximum length of orf name int meanZ = 0; int mult = 0; if(argc>2) { for(i=3;i<=argc;i++) { if(argv[i-1][0] == '-' && argv[i-1][1] == 'd') newD = atoi(argv[i-1]+2); if(argv[i-1][0] == '-' && argv[i-1][1] == 'o') newO = atoi(argv[i-1]+2); if(argv[i-1][0] == '-' && argv[i-1][1] == 'c') meanZ = 1; if(argv[i-1][0] == '-' && argv[i-1][1] == 'm') mult = 1; } } SimMat inputData(fullName,newO,newD,meanZ); // output files names char *cdtFile = nameFile(argv[1],".CDT",0); char *gtrFile = nameFile(argv[1],".GTR",0); char *inCdtFile = nameFile(argv[1],".CDT","In"); char *inGtrFile = nameFile(argv[1],".GTR","In"); char *atrFile = nameFile(argv[1],".ATR",0); float **mat = inputData.giveMat(); // similarity matrix int num = inputData.giveGenes(); Tree *t = createTree(num,mat,gtrFile,"GENE"); // hierarchical clustering tree copyFile(gtrFile,inGtrFile); float init = -1*t->curDist(mat); // initial ordering score cerr<<"Initial sum of similarities "<initOrder(); float min; int *arr = t->returnOrder(&min,num); // the optimal leaf algorithm call min = -1*min; cerr<<"Optimal sum of similarities: "<curDist(cMat); // initial ordering score int *orderC = tc->initOrder(); float minC; delete []arrC; arrC = tc->returnOrder(&minC,numC); // the optimal leaf algorithm call minC = -1*minC; cerr<<"Initial column similarity: "<giveNumLeafs(); lSize = allTrees[l]->giveNumLeafs(); #ifdef NOTNOW to<<"NODE"<isLeaf()) to<giveIndex()<<"X"<<'\t'; else to<<"NODE"<giveIndex()<<"X"<<'\t'; if(allTrees[r]->isLeaf()) to<giveIndex()<<"X"<<'\t'; else to<<"NODE"<giveIndex()<<"X"<<'\t'; to<initOrder(); float min; int *arr = t->returnOrder(&min,num); // the optimal leaf algorithm call return arr; } }