/usr/share/hyphy/ChartAddIns/Median Profile Plot 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 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 | if (NON_EMPTY_SELECTION)
{
UPDATE_CELL_DATA = 1;
data_rows = Columns (SELECTED_CHART_ROWS);
temp = SELECTED_CHART_COLS[0];
for (count = 1; count<data_rows; count = count+1)
{
temp2 = SELECTED_CHART_COLS[count];
if (temp!=temp2)
{
break;
}
}
if ((count == data_rows)&&(count>1))
/* proper selection */
{
windowWidth = 0;
while ((windowWidth<2)||(windowWidth>count)||(windowWidth%2==0))
{
fprintf (stdout, "\nChoose an ODD median profile window width in [3,",count,"]:");
fscanf (stdin, "Number", windowWidth);
}
medianLocation = windowWidth$2;
profileSnapshot = {windowWidth, 2};
medianDataMatrix = {data_rows,2};
for (kk=0; kk<windowWidth;kk=kk+1)
{
profileSnapshot[kk][0] = SELECTED_CHART_DATA[kk];
profileSnapshot[kk][1] = kk;
}
/* sort the first windowWidth elements by bubble sort
(hopefully the window is small!)*/
goOn = 1;
while (goOn)
{
goOn = 0;
for (kk=0; kk<windowWidth-1;kk=kk+1)
{
t1 = profileSnapshot[kk][0];
t2 = profileSnapshot[kk+1][0];
if (t2<t1)
{
profileSnapshot[kk+1][0] = t1;
profileSnapshot[kk][0] = t2;
t1 = profileSnapshot[kk+1][1];
profileSnapshot[kk+1][1] = profileSnapshot[kk][1];
profileSnapshot[kk][1] = t1;
goOn = 1;
}
}
}
t1 = profileSnapshot[medianLocation][0];
for (kk=0; kk<=medianLocation;kk=kk+1)
{
medianDataMatrix[kk][0] = SELECTED_CHART_DATA[kk];
medianDataMatrix[kk][1] = t1;
}
t2 = data_rows-medianLocation;
kk3 = 0;
t5 = kk+medianLocation;
for (;kk<t2;kk=kk+1)
{
for (kk2=0;kk2<windowWidth;kk2=kk2+1)
{
if (profileSnapshot[kk2][1] == kk3)
{
break;
}
}
kk3 = kk3+1;
t3 = SELECTED_CHART_DATA[t5];
profileSnapshot[kk2][0] = t3;
profileSnapshot[kk2][1] = t5;
t5 = t5+1;
t4 = kk2+1;
while (t4<windowWidth)
{
if (t3<=profileSnapshot[t4][0])
{
break;
}
t1 = profileSnapshot[t4][0];
profileSnapshot[t4][0] = profileSnapshot[kk2][0];
profileSnapshot[kk2][0] = t1;
t1 = profileSnapshot[t4][1];
profileSnapshot[t4][1] = profileSnapshot[kk2][1];
profileSnapshot[kk2][1] = t1;
kk2 = t4;
t4 = t4+1;
}
if (t4)
{
t4 = kk2-1;
while (t4>=0)
{
if (t3>=profileSnapshot[t4][0])
{
break;
}
t1 = profileSnapshot[t4][0];
profileSnapshot[t4][0] = profileSnapshot[kk2][0];
profileSnapshot[kk2][0] = t1;
t1 = profileSnapshot[t4][1];
profileSnapshot[t4][1] = profileSnapshot[kk2][1];
profileSnapshot[kk2][1] = t1;
kk2 = t4;
t4 = t4-1;
}
}
medianDataMatrix[kk][0] = SELECTED_CHART_DATA[kk];
medianDataMatrix[kk][1] = profileSnapshot[medianLocation][0];
}
t1 = profileSnapshot[medianLocation][0];
for (; kk<data_rows;kk=kk+1)
{
medianDataMatrix[kk][0] = SELECTED_CHART_DATA[kk];
medianDataMatrix[kk][1] = t1;
}
labelMatrix = {{"Data","Sliding median"}};
OpenWindow (CHARTWINDOW,{{"Median Profile"}
{"labelMatrix"},
{"medianDataMatrix"},
{"Bar Chart"},
{"Index"},
{labelMatrix[0]},
{"Index"},
{"Window("+windowWidth+") Median"},
{"Data"},
{"0"}
{"medianDataMatrix[_x_-1][1]"}
{"-1;-1"}
{"10;1.309;0.785398"}
{"Times:12:0;Times:10:0;Times:12:2"}
{"0;0;16777215;8421504;11776947;0;0;11842740;13158600;14474460;0;3947580;13421772;6845928;16771158;2984993;9199669;7018159;1460610;16748822;11184810;14173291"}
{"16"}},
"SCREEN_WIDTH-60;SCREEN_HEIGHT-50;30;50");
return 0;
}
fprintf (stdout, "Please select a single column with more than one entry to profile\n");
}
else
{
NON_EMPTY_SELECTION = -1;
}
|