path = HYPHY_BASE_DIRECTORY + "TemplateBatchFiles" + DIRECTORY_SEPARATOR + "Utility" + DIRECTORY_SEPARATOR + "ReadDelimitedFiles.bf"; ExecuteAFile (path); path = HYPHY_BASE_DIRECTORY + "TemplateBatchFiles" + DIRECTORY_SEPARATOR + "Utility" + DIRECTORY_SEPARATOR + "GrabBag.bf"; ExecuteAFile (path); path = HYPHY_BASE_DIRECTORY + "TemplateBatchFiles" + DIRECTORY_SEPARATOR + "TreeTools.ibf"; ExecuteAFile (path); SetDialogPrompt ("Select file containing Newick tree strings:"); fscanf (PROMPT_FOR_FILE, "Lines", newicks); SetDialogPrompt ("Select file containing g2p scores of observed sequences (tips):"); fscanf (PROMPT_FOR_FILE, "Lines", g2ps); /* header,refseq,aaseq,g2p,g2pFPR 0_36183A_54_5_735,CTRPN-NNT--RKSIRI---GPGQ---AFYAT----GDIIGDI--RQAHC,CTRPN-NNT--RKDIHI---GPGR---AMYAT----RQIIGNI--RQAHC,0.25548118689,5.3 now header,aaseq,g2p,g2pFPR 0_36183A_54_5_735,CTRPN-NNT--RKDIHI---GPGR---AMYAT----RQIIGNI--RQAHC,0.25548118689,5.3 */ /* build list of CXCR4-using sequences */ x4 = {}; for (i = 1; i < Columns(g2ps); i = i + 1) { items = splitOnRegExp (g2ps[i],"\\,"); if (items[3] == "None") { continue; } ExecuteCommands("fpr = "+items[3]+";"); if (fpr < 3.5) { x4[Abs(x4)] = items[0]; // append header } } SetDialogPrompt ("Select a file to record output:"); fprintf (PROMPT_FOR_FILE, CLEAR_FILE, KEEP_OPEN); outfile = LAST_FILE_PATH; ACCEPT_ROOTED_TREES = 1; ACCEPT_BRANCH_LENGTHS = 1; UseModel (USE_NO_MODEL); for (treerep = 0; treerep < Columns(newicks); treerep = treerep + 1) { /* convert Newick string to HyPhy associative list object */ Tree mytree = newicks[treerep]; tre = mytree^0; /* make new associative list with key, value pair (node name, AVL index) */ node2index = {}; for (i = 0; i < Abs(tre); i = i + 1) { key = (tre[i])["Name"]; node2index[key] = i; } /* get node indices of X4 tips */ nodei = {}; for (i = 0; i < Abs(x4); i = i + 1) { nodei[Abs(nodei)] = node2index[x4[i]]; } /* convert list of indices into integer vector */ nodeiv = avlToMatrix("nodei"); mrca = _findMRCA(tre, nodeiv); fprintf (outfile, treerep, ",", (tre[mrca])["Name"], "\n"); } fprintf (outfile, CLOSE_FILE);