This file is indexed.

/usr/share/hyphy/TemplateBatchFiles/AddABias.ibf 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
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
278
279
pThresh = 0.001;

/*--------------------------------------------------------------------------------------------*/

function AddABias (ModelMatrixName&, ModelMatrixName2&, biasedBase)
{
	ModelMatrixName2 = {20,20};
	
	t = 1;
	c = 1;
	_numericRateMatrix = ModelMatrixName;
	
	for (ri = 0; ri < 20; ri = ri+1)
	{
		for (ci = ri+1; ci < 20; ci = ci+1)
		{
			ModelMatrixName2[ri][ci] := _numericRateMatrix__[ri__][ci__] * t;
			ModelMatrixName2[ci][ri] := _numericRateMatrix__[ri__][ci__] * t;
		
		}
	}

	if (biasedBase < 20)
	{
		global rateBiasTo 	 = 2;
		global rateBiasFrom	:= 1/rateBiasTo;
		
		rateBiasTo   :>1;
		for (ri = 0; ri < 20; ri = ri+1)
		{
			if (ri != biasedBase)
			{
				ModelMatrixName2[ri][biasedBase] := _numericRateMatrix__[ri__][biasedBase__] * t * rateBiasTo;
				ModelMatrixName2[biasedBase][ri] := _numericRateMatrix__[ri__][biasedBase__] * t * rateBiasFrom;
			}
		}
	}

	return 1;
}

/*--------------------------------------------------------------------------------------------*/

function AddABiasREL (ModelMatrixName&, ModelMatrixName2&, biasedBase)
{
	ModelMatrixName2 = {20,20};
	
	t = 1;	/* branch length, local parameter */
	c = 1;	/* rate variation */
	_numericRateMatrix = ModelMatrixName;
	
	/* the probability that site is undergoing biased substitution rates */
	global	  P_bias = 0.1;  P_bias :< 0.5;
	
	
	category catVar = (2,{{1-P_bias,P_bias}},MEAN,,{{0,1}},0,1);
	
	for (ri = 0; ri < 20; ri = ri+1)
	{
		for (ci = ri+1; ci < 20; ci = ci+1)
		{
			ModelMatrixName2[ri][ci] := _numericRateMatrix__[ri__][ci__] * t * c;
			ModelMatrixName2[ci][ri] := _numericRateMatrix__[ri__][ci__] * t * c;
		
		}
	}

	if (biasedBase < 20)
	{
		global rateBiasTo 	  = 5.0;
		global rateBiasFrom	 := 1/rateBiasTo;
			
		rateBiasTo    :>1;
		relBias       :>1;	/* UNUSED ?!? */
		for (ri = 0; ri < 20; ri = ri+1)
		{
			if (ri != biasedBase)
			{
				ModelMatrixName2[ri][biasedBase] := _numericRateMatrix__[ri__][biasedBase__] * t * c * ((catVar==1)*rateBiasTo+(catVar==0));
				ModelMatrixName2[biasedBase][ri] := _numericRateMatrix__[ri__][biasedBase__] * t * c * ((catVar==1)*rateBiasFrom+(catVar==0));
			}
		}
	}

	return 1;
}

/*--------------------------------------------------------------------------------------------*/

function runAFit (refClass,ancClass,mySiteID)
{
	singletonScale 			= 1;
	DataSetFilter			aSite = CreateFilter (ds,1,siteIndex==mySiteID,speciesIndex<ds.species-2);
	deltaDistr	   			= {20,1}["_MATRIX_ELEMENT_ROW_=="+ancClass];
	LikelihoodFunction3	    singletonLF = (aSite, singletonTree, deltaDistr);
	Optimize 				(resS, singletonLF);
	AddABias 				(modelNameString,"biasedMatrix", refClass);
	Model biasedModel 		= (biasedMatrix, vectorOfFrequencies, 1);
	Tree biasedTree 		= treeString;
	global biasedScale	 	= 1;
	ReplicateConstraint 	("this1.?.t:=biasedScale*this2.?.t__",biasedTree,givenTree);
	LikelihoodFunction3	    biasedLF = (aSite, biasedTree, deltaDistr);
	Optimize 				(resB, biasedLF);
	
	checkIfDone = {};
	checkIfDone ["ref"] 	  = AAString[refClass];
	checkIfDone ["anc"] 	  = AAString[ancClass];
	checkIfDone ["p"]		  = 1-CChi2(2(resB[1][0]-resS[1][0]),1);
	checkIfDone ["bias"]	  = rateBiasTo;
	checkIfDone ["LL1"]	  	  = resS[1][0];
	checkIfDone ["LL2"]	  	  = resB[1][0];
	checkIfDone ["s1"]	  	  = singletonScale;
	checkIfDone ["s2"]	  	  = biasedScale;
	
	return checkIfDone;
}

/*--------------------------------------------------------------------------------------------*/

function runAFit2 (ancClass,mySiteID)
{
	DataSetFilter			aSite = CreateFilter (ds,1,siteIndex==mySiteID,speciesIndex<ds.species-2);
	COUNT_GAPS_IN_FREQUENCIES     = 0;
	HarvestFrequencies			  (siteFreqs,aSite,1,1,1);
	singletonScale 			= 1;

	DataSetFilter			aSite = CreateFilter (ds,1,siteIndex==mySiteID,speciesIndex<ds.species-2);
	deltaDistr	   			= {20,1}["_MATRIX_ELEMENT_ROW_=="+ancClass];
	LikelihoodFunction3	    singletonLF = (aSite, singletonTree, deltaDistr);
	Optimize 				(resS, singletonLF);
	
	checkIfDone = {};
	checkIfDone ["anc"] 	  = AAString[ancClass];
	checkIfDone ["LL1"]	  	  = resS[1][0];
	checkIfDone ["s1"]	  	  = singletonScale;
	checkIfDone ["p"]		  = 1;

	minP					  = 1;

	for (_resID = 0; _resID < 20; _resID = _resID + 1)
	{
		if (siteFreqs[_resID])
		{
			AddABias 				(modelNameString,"biasedMatrix", _resID);
			Model biasedModel 		= (biasedMatrix, vectorOfFrequencies, 1);
			Tree biasedTree 		= treeString;
			global biasedScale	 	= 1;
			ReplicateConstraint 	("this1.?.t:=biasedScale*this2.?.t__",biasedTree,givenTree);
			LikelihoodFunction3	    biasedLF = (aSite, biasedTree, deltaDistr);
			Optimize 				(resB, biasedLF);	
			pv						  = Min(20*(1-CChi2(2(resB[1][0]-resS[1][0]),1)),1);
			if (pv < minP)
			{
				minP = pv;
				checkIfDone ["ref"] 	  = AAString[_resID];
				checkIfDone ["bias"]	  = rateBiasTo;
				checkIfDone ["LL2"]	  	  = resB[1][0];
				checkIfDone ["s2"]	  	  = biasedScale;
				checkIfDone ["p"]		  = minP;
			}
		}
	}
	

	return checkIfDone;
}

/*--------------------------------------------------------------------------------------------*/

function promptModel (dummy)
{
	ChoiceList	     (pickAModel,"Subsitution Model",1,SKIP_NONE, "HIV Within","HIV Within",
							 								      "HIV Between","HIV Between",
							 								      "JTT","JTT",
							 								      "Flu H5N1", "Empirical model for H5N1 Influenza",
																  "LG", "Le-Gasquel 2008",
							 								      "REV", "Use general time-reversible model (WARNING: 189 rate parameters will be estimated from your alignment)");
							 								     
							 								    
	if (pickAModel < 0)
	{
		return 0;
	}

	modelSTDINoverload = {};
	modelSTDINoverload["2"] = "Rate variation";
	modelSTDINoverload["3"] = "Beta-Gamma";
	modelSTDINoverload["4"] = "4";
	modelNameString = "_customAAModelMatrix";

	if (pickAModel == 0)
	{
		modelSTDINoverload["0"] = HYPHY_LIB_DIRECTORY + "TemplateBatchFiles" + DIRECTORY_SEPARATOR + "TemplateModels" + DIRECTORY_SEPARATOR + "EmpiricalAA" + 
								  DIRECTORY_SEPARATOR + "HIVWithin";
	}

	if (pickAModel == 1)
	{
		modelSTDINoverload["0"] = HYPHY_LIB_DIRECTORY + "TemplateBatchFiles" + DIRECTORY_SEPARATOR + "TemplateModels" + DIRECTORY_SEPARATOR + "EmpiricalAA" + 
								  DIRECTORY_SEPARATOR + "HIVBetween";
	}

	if (pickAModel == 2)
	{
		modelSTDINoverload["0"] = HYPHY_LIB_DIRECTORY + "TemplateBatchFiles" + DIRECTORY_SEPARATOR + "TemplateModels" + DIRECTORY_SEPARATOR + "EmpiricalAA" + 
								  DIRECTORY_SEPARATOR + "JTT";
	}

	if (pickAModel == 3)
	{
		modelSTDINoverload["0"] = HYPHY_LIB_DIRECTORY + "TemplateBatchFiles" + DIRECTORY_SEPARATOR + "TemplateModels" + DIRECTORY_SEPARATOR + "EmpiricalAA" + 
								  DIRECTORY_SEPARATOR + "H5N1";
	}
	
	if (pickAModel == 4)
	{
		modelSTDINoverload["0"] = HYPHY_LIB_DIRECTORY + "TemplateBatchFiles" + DIRECTORY_SEPARATOR + "TemplateModels" + DIRECTORY_SEPARATOR + "EmpiricalAA" + 
								  DIRECTORY_SEPARATOR + "LG";
	}

	if (pickAModel < 5)
	{
		/* estimate base frequencies as model parameters */
		modelSTDINoverload["1"]	= "ML Estimates";
		modelPath = HYPHY_LIB_DIRECTORY + "TemplateBatchFiles" + DIRECTORY_SEPARATOR + "TemplateModels" + DIRECTORY_SEPARATOR + "Custom_AA_empirical.mdl";
	}
	else
	{
		modelNameString = "mtREVMatrix";
		modelPath = HYPHY_LIB_DIRECTORY + "TemplateBatchFiles" + DIRECTORY_SEPARATOR + "TemplateModels" + DIRECTORY_SEPARATOR + "mtREV.mdl";	
	}
	
	ExecuteAFile (modelPath,modelSTDINoverload);

	if (dummy)
	{
		ChoiceList	     (pickATarget,"Target residue",1,SKIP_NONE, "Fixed","Fixed Sequence",
							 								    "Inferred","Inferred Sequence");
	}						 								    
	return pickAModel;
}

/*--------------------------------------------------------------------------------------------*/

function processAJob (mySiteID)
{
	if (MPI_NODE_COUNT > 1)
	{
		MPIReceive 					(-1,fromNode,mpiResults);
		mySiteID 					= MPINodeStatus[fromNode-1];
		ExecuteCommands 			(mpiResults);
		checkIfDone 			  = _hyphyAssociativeArray;
	}
		
	fprintf (stdout, "\nSite ", mySiteID+1, 
					 "\n\t Character : ", checkIfDone ["anc"],"->",checkIfDone ["ref"],
					 "\n\t Bias term : ", checkIfDone ["bias"],
					 "\n\t LogL std  : ", checkIfDone ["LL1"],
					 "\n\t LogL bias : ", checkIfDone ["LL2"],
					 "\n\t Scale std : ", checkIfDone ["s1"],
					 "\n\t Scale bias: ", checkIfDone ["s2"],
					 "\n\t p-value   : ", checkIfDone ["p"]);
					 
	fprintf (outPath, "\nSite ", mySiteID+1, 
					 "\n\t Character : ", checkIfDone ["anc"],"->",checkIfDone ["ref"],
					 "\n\t Bias term : ", checkIfDone ["bias"],
					 "\n\t LogL std  : ", checkIfDone ["LL1"],
					 "\n\t LogL bias : ", checkIfDone ["LL2"],
					 "\n\t Scale std : ", checkIfDone ["s1"],
					 "\n\t Scale bias: ", checkIfDone ["s2"],
					 "\n\t p-value   : ", checkIfDone ["p"]);

	if (checkIfDone ["p"] < pThresh)
	{
		mx2 = smx;
		strongEvidence[Abs(strongEvidence)] = mx2;
	}
	return fromNode-1;
}