/usr/share/hyphy/DatapanelAddIns/Sequence Plot is in hyphy-common 2.2.6+dfsg-3build3.
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 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 | RequireVersion ("0.9920060502");
ChoiceList (_idx, "Colors", 1, SKIP_NONE, "Default Colors", "Use the default (20 character) amino-acid palette","Black", "All characters are black");
if (_idx<0)
{
return 0;
}
_charColorList = {};
if (_idx == 0)
{
ExecuteCommands ("#include \"ibfs/char_colors.def\";");
}
_idx = "`HYPHY_LIB_DIRECTORY`TemplateBatchFiles`DIRECTORY_SEPARATOR`Utility`DIRECTORY_SEPARATOR`GrabBag.bf";
ExecuteCommands ("#include\"`_idx`\";");
_idx = "`HYPHY_LIB_DIRECTORY`TemplateBatchFiles`DIRECTORY_SEPARATOR`Utility`DIRECTORY_SEPARATOR`PostScript.bf";
ExecuteCommands ("#include\"`_idx`\";");
_seqCount = Columns(_DATAPANEL_SELECTED_SEQUENCES_);
_selFilters = Columns(_DATAPANEL_SELECTED_FILTERS_);
if (_selFilters > 1)
{
fprintf (stdout, "ERROR: This plug in-needs none or one selected data filter\n");
return 0;
}
_unitSize = _DATAPANEL_UNIT_SIZE_[0];
if (_unitSize!=1)
{
fprintf (stdout, "ERROR: This plug can only accept filters with unit size of one\n");
return 0;
}
if (_selFilters)
{
_baseName = _DATAPANEL_SELECTED_FILTERS_[0];
}
else
{
_baseName = _DATAPANEL_DATASET_NAME_;
}
_sequenceMapping = {};
_haveReference = -1;
_exclusions = _DATAPANEL_EXCLUSIONS_[0];
_font_size = 8;
_char_space = _font_size;
_page_w = 792;
_page_h = 612;
_atom = 5;
_seqCaps = {};
_idx2 = 0;
for (_idx = 0; _idx < _DATAPANEL_DATAFILTER_.species; _idx = _idx+1)
{
GetString (_capOffset, _DATAPANEL_DATAFILTER_, _idx);
_idx2 = Max (_idx2, Abs(_capOffset));
_seqCaps [_idx] = _capOffset;
}
_capOffset = (_idx2)*_font_size*0.8$1;
DEFAULT_FILE_SAVE_NAME = _baseName + ".ps";
SetDialogPrompt ("Save PostScript graphics to:");
fprintf (PROMPT_FOR_FILE,CLEAR_FILE,KEEP_OPEN,_HYPSPageHeader (_page_w,_page_h,"Character Plot for "+_baseName),
_HYPSSetFont ("Courier",_font_size),
"/dmx 6 array currentmatrix def\n",
"/sshift fs 2 idiv fs add def\n",
"/setb {0 0 0 setrgbcolor} def\n",
"/dobox {setrgbcolor newpath 2 copy moveto 4 -1 roll exch 2 copy lineto exch 4 -1 roll 2 copy lineto 4 -1 roll exch lineto pop pop closepath} def\n",
"/flbx {dobox fill setb} def\n",
"/stbx {dobox stroke setb} def\n",
"/drln {setrgbcolor newpath moveto lineto stroke setb} def\n",
"/drawletter {translate scale newpath 0 0 moveto false charpath fill dmx setmatrix} def\n"
);
outFile = LAST_FILE_PATH;
_page_w = _page_w-_capOffset;
_selFilters = Columns(_DATAPANEL_SELECTED_FILTERS_);
GetDataInfo (_charHandles, _DATAPANEL_DATAFILTER_, "CHARACTERS");
_ccount = Columns (_charHandles);
_unit = {1,_ccount}["1"];
_char_per_line = _page_w / _char_space $ _atom * _atom;
if (_char_per_line == 0)
{
fprintf (stdout, "\nERROR: At least ",_atom," characters must fit in a line; reduce font size in 'Sequence Plot' source\n");
}
else
{
fprintf (stdout, "\n", _char_per_line, " characters per line\n");
}
_current_x = _capOffset;
_xtra_spacing = _font_size$2 + 1;
_current_y = _page_h-(1+_DATAPANEL_DATAFILTER_.species)*_font_size-_xtra_spacing;
GetInformation (_rawStrings, _DATAPANEL_DATAFILTER_);
for (_idx = 0; _idx < _DATAPANEL_DATAFILTER_.sites; _idx = _idx + 1)
{
/*if (Rows (_cCounter) == 1 && Rows (_cCounter2) == 1)
{
if (_cCounter[0][1] != _cCounter2[0][1])
{
fprintf (outFile, _current_x, " ", _current_y+_font_size-_font_size$4-1, " ", _current_x + _char_space , " ", _current_y - _dbyLine1[_cl]*_font_size - 2, " 0.2 0.2 0.2 stbx\n");
}
}*/
_ref_c = (_rawStrings[0])[_idx];
for (_sidx = _DATAPANEL_DATAFILTER_.species-1; _sidx >= 0; _sidx = _sidx - 1)
{
_my_c = (_rawStrings[_sidx])[_idx];
if (_sidx && _my_c == _ref_c)
{
_my_c = ".";
}
if (Abs(_charColorList[_my_c]))
{
fprintf (outFile, _charColorList[_my_c], " setrgbcolor\n");
}
fprintf (outFile, "(",_my_c,") 1 1 ", _current_x, " ", _current_y+_font_size*(_DATAPANEL_DATAFILTER_.species-1-_sidx), " drawletter\n");
if (Abs(_charColorList[_my_c]))
{
fprintf (outFile, "setb\n");
}
}
_current_x = _current_x + _char_space;
if ((_idx + 1)%_char_per_line==0 || _idx == _DATAPANEL_DATAFILTER_.sites-1)
{
for (_sidx = _DATAPANEL_DATAFILTER_.species-1; _sidx >= 0; _sidx = _sidx - 1)
{
fprintf (outFile, "0 ", _current_y+_font_size*(_DATAPANEL_DATAFILTER_.species-1-_sidx), " moveto (",_seqCaps[_sidx],") show\n");
}
_current_y = _current_y + _DATAPANEL_DATAFILTER_.species*_font_size;
if (_idx == _DATAPANEL_DATAFILTER_.sites-1)
{
if (_DATAPANEL_DATAFILTER_.sites % _char_per_line == 0)
{
_startx = _char_per_line;
}
else
{
_startx = _DATAPANEL_DATAFILTER_.sites%_char_per_line$_atom*_atom;
}
_idx2 = _DATAPANEL_DATAFILTER_.sites-_DATAPANEL_DATAFILTER_.sites%_char_per_line;
}
else
{
_idx2 = _idx - _char_per_line + 1;
_startx = _char_per_line;
}
/*fprintf (outFile, "0 ", _current_y - _font_size, " moveto (", _seqCaps[0], ") show\n");
fprintf (outFile, "0 ", _current_y2, " moveto (", _seqCaps[1], ") show\n");*/
fprintf (outFile, _capOffset, " ", _current_y + _font_size * 4$5, " ", _capOffset + _char_space*(1+_char_per_line) , " ", _current_y - _font_size$4, " 0.9 0.9 0.9 flbx\n");
for (_idx3 = _startx; _idx3 > 0; _idx3 = _idx3 - _atom)
{
fprintf (outFile, "(",_idx2+_idx3,") 0.9 0.9 ", _capOffset + (_idx3-1) * _char_space, " ", _current_y, " drawletter\n");
}
_current_x = _capOffset;
_current_y = _current_y - (1+2*_DATAPANEL_DATAFILTER_.species)*_font_size - _xtra_spacing;
_cl = _cl+1;
if (_current_y < 0)
{
_current_y = _page_h-(1+_DATAPANEL_DATAFILTER_.species)*_font_size - _xtra_spacing;
fprintf (outFile, "showpage\n");
}
}
}
fprintf (outFile, CLOSE_FILE);
|