/usr/share/hyphy/UserAddins/CountSubstitutions is in hyphy-common 2.2.7+dfsg-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 | /* modified MapSubstitutions to produce a matrix of the number of subs in each nuc subs class
Wayne Delport 30 April 2009
*/
ExecuteAFile (HYPHY_LIB_DIRECTORY+"TemplateBatchFiles"+
DIRECTORY_SEPARATOR+"Utility" +
DIRECTORY_SEPARATOR+"AncestralMapper.bf");
likelihoodFnChoice = 0;
if (Rows("LikelihoodFunction")>1)
{
ChoiceList (likelihoodFnChoice,"Choose a Likelihood Function",1,NO_SKIP,LikelihoodFunction);
}
if (likelihoodFnChoice<0)
{
return;
}
GetString (LF_NAME,LikelihoodFunction,likelihoodFnChoice);
ExecuteCommands ("GetString(_lfInfo,"+LF_NAME+",-1);");
_lfPart = Columns (_lfInfo["Datafilters"]);
if (_lfPart > 1)
{
choices = {_lfPart, 2};
for (k = 0; k < _lfPart; k = k+1)
{
choices [k][0] = (_lfInfo["Datafilters"])[k];
choices [k][1] = "Associated tree " + (_lfInfo["Trees"])[k];
}
ChoiceList (_lfPart,"Which data filter?",1,NO_SKIP,choices);
}
else
{
_lfPart = 0;
}
if (_lfPart >= 0) {
aid = _buildAncestralCacheInternal (LF_NAME, _lfPart, 0);
fd = _filterDimensions (aid);
for (k = 0; k < fd[0]; k=k+1) {
temparray = _substitutionsBySite ( aid, k );
if ( k == 0 ) {
sumArrays = { Columns(temparray["CHARS"]), Columns(temparray["CHARS"]) };
for ( r = 0; r < Columns(temparray["CHARS"]); r = r + 1 ) { /* better way to initialize? */
for ( c = 0; c < Columns(temparray["CHARS"]); c = c + 1 ) {
sumArrays [ r ][ c ] = 0;
}
}
}
/* fprintf ( stdout, temparray["COUNTS"], "\n" ); */
sumArrays = sumArrays + temparray["COUNTS"];
}
fprintf ( stdout, "Inferred number of substitutions\n" );
fprintf ( stdout, "--------------------------------\n\t" );
alphabet = temparray["CHARS"];
for ( i = 0; i < Columns(alphabet); i = i + 1 ) {
fprintf ( stdout, alphabet[i], "\t");
}
fprintf ( stdout, "\n" );
for ( i = 0; i < Columns(alphabet); i = i + 1 ) {
for ( j = 0; j < Columns(alphabet); j = j + 1 ) {
if ( j == 0 ) {
fprintf ( stdout, alphabet [ i ], "\t" );
}
if ( i != j ) {
fprintf ( stdout, sumArrays [ i ][ j ], "\t" );
}
else {
fprintf ( stdout, "*\t" );
}
}
fprintf ( stdout, "\n" );
}
/* fprintf ( stdout, sumArrays, "\n" ); */
SetDialogPrompt ("Save to:");
fprintf (PROMPT_FOR_FILE, CLEAR_FILE, KEEP_OPEN);
fprintf ( LAST_FILE_PATH, temparray["CHARS"] );
fprintf ( LAST_FILE_PATH, sumArrays, "\n" );
fprintf (LAST_FILE_PATH,CLOSE_FILE);
_destroyAncestralCache (aid);
}
|