This file is indexed.

/usr/share/hyphy/TemplateBatchFiles/SlidingWindowAnalysis.bf 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
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
fprintf(stdout,"\n ---- RUNNING SLIDING DATA WINDOW ANALYSIS ---- \n");

ChoiceList (dataType,"Data type",1,SKIP_NONE,"Nucleotide/Protein","Nucleotide or amino-acid (protein).",
				     "Codon","Codon (several available genetic codes).");

if (dataType<0) 
{
	return;
}

if (dataType)
{
	SetDialogPrompt ("Please choose a codon data file:");
	#include "TemplateModels/chooseGeneticCode.def";
}
else
{
	SetDialogPrompt ("Please choose a nucleotide or amino-acid data file:");
}

DataSet ds = ReadDataFile (PROMPT_FOR_FILE);

fprintf (stdout,"\n\n**** Read file ", LAST_FILE_PATH," ****\n**** ", Format(ds.sites,0,0)," sites (", 
				Format(ds.unique_sites,0,0)," of them are distinct), and ", Format(ds.species,0,0), " species. ****"); 

if (IS_TREE_PRESENT_IN_DATA)
{
	treeString = DATAFILE_TREE;
	fprintf (stdout, "\n\nA tree was found in the data file:\n",treeString,"\n\nWould you like to use it:(Y/N)?");
	fscanf (stdin, "String", response);
	if ((response=="n")||(response=="N"))
	{
		IS_TREE_PRESENT_IN_DATA = 0;
	}
	fprintf (stdout, "\n\n");
}

if (!IS_TREE_PRESENT_IN_DATA)
{
	SetDialogPrompt ("Please select a tree file for the data:");
	fscanf (PROMPT_FOR_FILE, "String", treeString);
}

if (dataType)
{
	DataSetFilter filteredData = CreateFilter (ds,3);
}
else
{
	DataSetFilter filteredData = CreateFilter (ds,1);
}

SetDialogPrompt		("Save results to:");
fprintf 			(PROMPT_FOR_FILE,CLEAR_FILE);
SelectTemplateModel (filteredData);

windowWidth:>0;
windowShift:>0;

windowWidth = 0;
windowShift = 0;

if (dataType)
{
	while (windowWidth<3 || windowWidth> filteredData.sites*3-3 || windowWidth%3)
	{
		fprintf (stdout,"\nEnter the width (in bp, divisble by 3) of the data window [3-",filteredData.sites*3-3,"]:");
		fscanf  (stdin,"Number",windowWidth);
	}
	firstTime = filteredData.sites*3-windowWidth;
	while (windowShift<3 || windowShift> firstTime || windowShift%3)
	{
		fprintf (stdout,"\nEnter the stride (in bp, divisble by 3) at each step [3-",firstTime,"]:");
		fscanf  (stdin,"Number",windowShift);
	}
}
else
{
	while (windowWidth<1 || windowWidth> filteredData.sites-1)
	{
		fprintf (stdout,"\nEnter the width (in bp) of the data window [1-",filteredData.sites-1,"]:");
		fscanf  (stdin,"Number",windowWidth);
	}
	firstTime = filteredData.sites-windowWidth;
	while (windowShift<1 || windowShift> firstTime)
	{
		fprintf (stdout,"\nEnter the stride (in bp) at each step [1-",firstTime,"]:");
		fscanf  (stdin,"Number",windowShift);
	}
}

fprintf (stdout,"\n");

MESSAGE_LOGGING = 0;
VERBOSITY_LEVEL = -1;

firstTime = 1;

if (MPI_NODE_COUNT>1)
{
	MPINodeState  = {MPI_NODE_COUNT-1,1};
	MPINodeBounds = {MPI_NODE_COUNT-1,2};
	OPTIMIZE_SUMMATION_ORDER = 0;
}

for (currentStart = 0; currentStart < ds.sites; currentStart = currentStart + windowShift)
{
	currentEnd = currentStart + windowWidth;
	if (currentEnd>=ds.sites)
	{
		currentEnd = ds.sites - 1;
	}
	
	if (dataType)
	{
		DataSetFilter filteredData = CreateFilter (ds,3,(siteIndex>=currentStart)&&(siteIndex<=currentEnd),"",GeneticCodeExclusions);
	}
	else
	{
		DataSetFilter filteredData = CreateFilter (ds,1,(siteIndex>=currentStart)&&(siteIndex<=currentEnd));
	}

	HarvestFrequencies (swEFV,filteredData,1,1,1);
	
	if (FREQUENCY_SENSITIVE)
	{
		swModelMatrix = 0;
		if (USE_POSITION_SPECIFIC_FREQS)
		{
			HarvestFrequencies (swEFV,filteredData,3,1,1);
		}
		MULTIPLY_BY_FREQS = PopulateModelMatrix ("swModelMatrix",swEFV);
		if (dataType)
		{
			swCodonEFV    = BuildCodonFrequencies (swEFV);
			Model swModel = (swModelMatrix,swCodonEFV,MULTIPLY_BY_FREQS);	
		}
		else
		{
			Model swModel = (swModelMatrix,swEFV,MULTIPLY_BY_FREQS);
		}	
	}
	
	Tree dataTree 		  = treeString;
	LikelihoodFunction lf = (filteredData,dataTree);

	if (MPI_NODE_COUNT>1)
	{
		for (mpiNode = 0; mpiNode < MPI_NODE_COUNT-1; mpiNode = mpiNode+1)
		{
			if (MPINodeState[mpiNode]==0)
			{
				break;	
			}
		}
		
		if (mpiNode==MPI_NODE_COUNT-1)
		/* all nodes busy */
		{
			mpiNode = ReceiveJobs (1);
		}
		else
		{
			MPISend (mpiNode+1,lf);
			MPINodeState[mpiNode] = 1;
			MPINodeBounds[mpiNode][0] = currentStart;
			MPINodeBounds[mpiNode][1] = currentEnd;
		}
	}
	else
	{
		Optimize (lf_MLES,lf);
		segmentStart = currentStart;
		segmentEnd   = currentEnd;
		dummy = ReceiveJobs (0);
	}
}

if (MPI_NODE_COUNT>1)
{
	while (1)
	{
		for (nodeCounter = 0; nodeCounter < MPI_NODE_COUNT-1; nodeCounter = nodeCounter+1)
		{
			if (MPINodeState[nodeCounter]==1)
			{
				fromNode = ReceiveJobs (0);
				break;	
			}
		}
		if (nodeCounter == MPI_NODE_COUNT-1)
		{
			break;
		}
	}	
	OPTIMIZE_SUMMATION_ORDER = 1;
	
	for (nodeCounter = 0; nodeCounter*windowShift < ds.sites; nodeCounter=nodeCounter+1)
	{
		fprintf (LAST_FILE_PATH,"\n",Format(nodeCounter*windowShift,0,0)," , ",
									 Format(Min((1+nodeCounter)*windowShift,ds.sites-1),0,0),",",MPI_Results_Cache[dataDimension][nodeCounter]);	
		
		for (i=0;i<dataDimension;i=i+1)
		{
			fprintf (LAST_FILE_PATH,",",MPI_Results_Cache[i][nodeCounter]);
		}			
	}
}


function ReceiveJobs (sendOrNot)
{
	if (MPI_NODE_COUNT>1)
	{
		MPIReceive (-1, fromNode, result_String);
		
		segmentStart = MPINodeBounds[fromNode-1][0];
		segmentEnd   = MPINodeBounds[fromNode-1][1];
		
		if (sendOrNot)
		{
			MPISend (fromNode,lf);
			MPINodeBounds[fromNode-1][0] = currentStart;
			MPINodeBounds[fromNode-1][1] = currentEnd;
		}
		else
		{
			MPINodeState[fromNode-1] = 0;
			MPINodeBounds[fromNode-1][0] = -1;
			MPINodeBounds[fromNode-1][1] = -1;
		}
		ExecuteCommands (result_String);
	}
	
	if (firstTime)
	{
		firstTime = 0;
		
		dataDimension = Columns(lf_MLES);
		
		fprintf (LAST_FILE_PATH,"\nStarting bp,Ending bp,Ln-likelihood");
		for (i=0;i<dataDimension;i=i+1)
		{
			GetString (argName,lf,i);
			fprintf	  (LAST_FILE_PATH,",",argName);
		}
		
		if (MPI_NODE_COUNT>1)
		{
			MPI_Results_Cache = {dataDimension+1,ds.sites$windowShift+1};
		}
	}	
	
	fprintf (stdout,"Finshed Segment ",Format(segmentStart,0,0)," - ",Format(segmentEnd,0,0),"\n");
	if (MPI_NODE_COUNT<2)
	{
		fprintf (LAST_FILE_PATH,"\n",Format(segmentStart,0,0)," , ",Format(segmentEnd,0,0),",",lf_MLES[1][0]);
		
		for (i=0;i<dataDimension;i=i+1)
		{
			fprintf (LAST_FILE_PATH,",",lf_MLES[0][i]);
		}			
	}
	else
	{
		cacheIndex = segmentStart $ windowShift;
		for (i=0;i<dataDimension;i=i+1)
		{
			MPI_Results_Cache[i][cacheIndex] = lf_MLES[0][i];
		}			
		MPI_Results_Cache[i][cacheIndex] = lf_MLES[1][0];
	}
	return fromNode-1;
}


MESSAGE_LOGGING = 1;