This file is indexed.

/usr/share/hyphy/TemplateBatchFiles/SeqAlignShared.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
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
alignOptions = {};

alignOptions ["SEQ_ALIGN_CHARACTER_MAP"]="ARNDCQEGHILKMFPSTWYV";

ChoiceList (refSeq,"Scoring Matrix",1,SKIP_NONE,"BLOSUM62","Default BLAST BLOSUM62 matrix",
												"HIV 5%","Empirically derived 5% divergence HIV matrix",
												"HIV 25%","Empirically derived 25% divergence HIV matrix",
												"HIV 50%","Empirically derived 50% divergence HIV matrix");

if (refSeq < 0)
{
	return 0;
	
}
if (refSeq == 0)
{
/*
# Divergence level: 0.38
# Matrix from: TeraMonkey:Users:sergei:hyphy:trunk:TemplateBatchFiles:TemplateModels:EmpiricalAA:BLOSUM62
# Expected score: -0.548341 Entropy: 4.88752 bits
     A   R   N   D   C   Q   E   G   H   I   L   K   M   F   P   S   T   W   Y   V   B   Z   X   *
A    6  -3  -4  -4  -2  -2  -2  -1  -3  -3  -3  -2  -2  -4  -2   0  -1  -5  -3  -1  -4  -2  -2  -7
R   -3   8  -2  -4  -6   0  -2  -5  -2  -6  -4   1  -3  -5  -4  -2  -3  -5  -3  -5  -3  -1  -2  -7
N   -4  -2   8   0  -5  -1  -2  -2   0  -6  -6  -1  -4  -5  -4   0  -1  -7  -4  -5   6  -2  -2  -7
D   -4  -4   0   8  -6  -2   0  -3  -3  -5  -6  -2  -6  -6  -3  -1  -3  -7  -6  -6   6   0  -3  -7
C   -2  -6  -5  -6  10  -5  -7  -5  -5  -3  -3  -6  -3  -5  -5  -2  -2  -4  -4  -2  -5  -6  -4  -7
Q   -2   0  -1  -2  -5   8   1  -4   0  -6  -4   0  -1  -6  -3  -1  -2  -3  -3  -4  -1   6  -2  -7
E   -2  -2  -2   0  -7   1   7  -4  -1  -6  -5   0  -4  -6  -3  -1  -2  -5  -4  -4   0   6  -2  -7
G   -1  -5  -2  -3  -5  -4  -4   7  -4  -7  -6  -3  -5  -5  -4  -2  -4  -4  -5  -6  -2  -4  -4  -7
H   -3  -2   0  -3  -5   0  -1  -4  10  -6  -5  -2  -3  -3  -4  -2  -4  -5   0  -6  -1  -1  -3  -7
I   -3  -6  -6  -5  -3  -6  -6  -7  -6   6   0  -5   0  -1  -5  -5  -2  -5  -3   2  -5  -6  -2  -7
L   -3  -4  -6  -6  -3  -4  -5  -6  -5   0   6  -5   1  -1  -5  -5  -3  -3  -3   0  -6  -5  -2  -7
K   -2   1  -1  -2  -6   0   0  -3  -2  -5  -5   7  -3  -6  -2  -1  -2  -5  -3  -4  -2   0  -2  -7
M   -2  -3  -4  -6  -3  -1  -4  -5  -3   0   1  -3   9  -1  -5  -3  -2  -3  -3   0  -5  -2  -1  -7
F   -4  -5  -5  -6  -5  -6  -6  -5  -3  -1  -1  -6  -1   8  -6  -4  -4   0   1  -3  -6  -6  -3  -7
P   -2  -4  -4  -3  -5  -3  -3  -4  -4  -5  -5  -2  -5  -6   9  -2  -3  -6  -5  -4  -4  -3  -4  -7
S    0  -2   0  -1  -2  -1  -1  -2  -2  -5  -5  -1  -3  -4  -2   7   0  -5  -3  -4  -1  -1  -2  -7
T   -1  -3  -1  -3  -2  -2  -2  -4  -4  -2  -3  -2  -2  -4  -3   0   7  -4  -3  -1  -2  -2  -2  -7
W   -5  -5  -7  -7  -4  -3  -5  -4  -5  -5  -3  -5  -3   0  -6  -5  -4  12   0  -6  -7  -4  -4  -7
Y   -3  -3  -4  -6  -4  -3  -4  -5   0  -3  -3  -3  -3   1  -5  -3  -3   0   9  -3  -5  -3  -2  -7
V   -1  -5  -5  -6  -2  -4  -4  -6  -6   2   0  -4   0  -3  -4  -4  -1  -6  -3   6  -6  -4  -2  -7
B   -4  -3   6   6  -5  -1   0  -2  -1  -5  -6  -2  -5  -6  -4  -1  -2  -7  -5  -6   7  -1  -3  -7
Z   -2  -1  -2   0  -6   6   6  -4  -1  -6  -5   0  -2  -6  -3  -1  -2  -4  -3  -4  -1   7  -2  -7
X   -2  -2  -2  -3  -4  -2  -2  -4  -3  -2  -2  -2  -1  -3  -4  -2  -2  -4  -2  -2  -3  -2  -2  -7
*   -7  -7  -7  -7  -7  -7  -7  -7  -7  -7  -7  -7  -7  -7  -7  -7  -7  -7  -7  -7  -7  -7  -7   1
*/

scoreMatrix = 
	{
	{                 6,                -3,                -4,                -4,                -2,                -2,                -2,                -1,                -3,                -3,                -3,                -2,                -2,                -4,                -2,                 0,                -1,                -5,                -3,                -1,                -4,                -2,                -2,                -7}
	{                -3,                 8,                -2,                -4,                -6,                 0,                -2,                -5,                -2,                -6,                -4,                 1,                -3,                -5,                -4,                -2,                -3,                -5,                -3,                -5,                -3,                -1,                -2,                -7}
	{                -4,                -2,                 8,                 0,                -5,                -1,                -2,                -2,                 0,                -6,                -6,                -1,                -4,                -5,                -4,                 0,                -1,                -7,                -4,                -5,                 6,                -2,                -2,                -7}
	{                -4,                -4,                 0,                 8,                -6,                -2,                 0,                -3,                -3,                -5,                -6,                -2,                -6,                -6,                -3,                -1,                -3,                -7,                -6,                -6,                 6,                 0,                -3,                -7}
	{                -2,                -6,                -5,                -6,                10,                -5,                -7,                -5,                -5,                -3,                -3,                -6,                -3,                -5,                -5,                -2,                -2,                -4,                -4,                -2,                -5,                -6,                -4,                -7}
	{                -2,                 0,                -1,                -2,                -5,                 8,                 1,                -4,                 0,                -6,                -4,                 0,                -1,                -6,                -3,                -1,                -2,                -3,                -3,                -4,                -1,                 6,                -2,                -7}
	{                -2,                -2,                -2,                 0,                -7,                 1,                 7,                -4,                -1,                -6,                -5,                 0,                -4,                -6,                -3,                -1,                -2,                -5,                -4,                -4,                 0,                 6,                -2,                -7}
	{                -1,                -5,                -2,                -3,                -5,                -4,                -4,                 7,                -4,                -7,                -6,                -3,                -5,                -5,                -4,                -2,                -4,                -4,                -5,                -6,                -2,                -4,                -4,                -7}
	{                -3,                -2,                 0,                -3,                -5,                 0,                -1,                -4,                10,                -6,                -5,                -2,                -3,                -3,                -4,                -2,                -4,                -5,                 0,                -6,                -1,                -1,                -3,                -7}
	{                -3,                -6,                -6,                -5,                -3,                -6,                -6,                -7,                -6,                 6,                 0,                -5,                 0,                -1,                -5,                -5,                -2,                -5,                -3,                 2,                -5,                -6,                -2,                -7}
	{                -3,                -4,                -6,                -6,                -3,                -4,                -5,                -6,                -5,                 0,                 6,                -5,                 1,                -1,                -5,                -5,                -3,                -3,                -3,                 0,                -6,                -5,                -2,                -7}
	{                -2,                 1,                -1,                -2,                -6,                 0,                 0,                -3,                -2,                -5,                -5,                 7,                -3,                -6,                -2,                -1,                -2,                -5,                -3,                -4,                -2,                 0,                -2,                -7}
	{                -2,                -3,                -4,                -6,                -3,                -1,                -4,                -5,                -3,                 0,                 1,                -3,                 9,                -1,                -5,                -3,                -2,                -3,                -3,                 0,                -5,                -2,                -1,                -7}
	{                -4,                -5,                -5,                -6,                -5,                -6,                -6,                -5,                -3,                -1,                -1,                -6,                -1,                 8,                -6,                -4,                -4,                 0,                 1,                -3,                -6,                -6,                -3,                -7}
	{                -2,                -4,                -4,                -3,                -5,                -3,                -3,                -4,                -4,                -5,                -5,                -2,                -5,                -6,                 9,                -2,                -3,                -6,                -5,                -4,                -4,                -3,                -4,                -7}
	{                 0,                -2,                 0,                -1,                -2,                -1,                -1,                -2,                -2,                -5,                -5,                -1,                -3,                -4,                -2,                 7,                 0,                -5,                -3,                -4,                -1,                -1,                -2,                -7}
	{                -1,                -3,                -1,                -3,                -2,                -2,                -2,                -4,                -4,                -2,                -3,                -2,                -2,                -4,                -3,                 0,                 7,                -4,                -3,                -1,                -2,                -2,                -2,                -7}
	{                -5,                -5,                -7,                -7,                -4,                -3,                -5,                -4,                -5,                -5,                -3,                -5,                -3,                 0,                -6,                -5,                -4,                12,                 0,                -6,                -7,                -4,                -4,                -7}
	{                -3,                -3,                -4,                -6,                -4,                -3,                -4,                -5,                 0,                -3,                -3,                -3,                -3,                 1,                -5,                -3,                -3,                 0,                 9,                -3,                -5,                -3,                -2,                -7}
	{                -1,                -5,                -5,                -6,                -2,                -4,                -4,                -6,                -6,                 2,                 0,                -4,                 0,                -3,                -4,                -4,                -1,                -6,                -3,                 6,                -6,                -4,                -2,                -7}
	{                -4,                -3,                 6,                 6,                -5,                -1,                 0,                -2,                -1,                -5,                -6,                -2,                -5,                -6,                -4,                -1,                -2,                -7,                -5,                -6,                 7,                -1,                -3,                -7}
	{                -2,                -1,                -2,                 0,                -6,                 6,                 6,                -4,                -1,                -6,                -5,                 0,                -2,                -6,                -3,                -1,                -2,                -4,                -3,                -4,                -1,                 7,                -2,                -7}
	{                -2,                -2,                -2,                -3,                -4,                -2,                -2,                -4,                -3,                -2,                -2,                -2,                -1,                -3,                -4,                -2,                -2,                -4,                -2,                -2,                -3,                -2,                -2,                -7}
	{                -7,                -7,                -7,                -7,                -7,                -7,                -7,                -7,                -7,                -7,                -7,                -7,                -7,                -7,                -7,                -7,                -7,                -7,                -7,                -7,                -7,                -7,                -7,                 1}
	};
}

if (refSeq == 1)
{

// HIV-1 between 5%
/*
     A   R   N   D   C   Q   E   G   H   I   L   K   M   F   P   S   T   W   Y   V   B   Z   X   *
A    8 -13 -16  -8 -15 -17  -8  -7 -16 -14 -14 -17 -16 -20  -7  -7  -2 -23 -23  -4 -10 -10  -8 -24
R  -13   8 -12 -20 -12  -6 -15  -6  -3 -11 -11  -1  -7 -21  -9  -6  -7 -10 -18 -16 -14  -8  -7 -24
N  -16 -12   9  -1 -15 -11 -14 -12  -4 -11 -20  -4 -19 -20 -17  -2  -4 -24  -8 -18   7 -12  -7 -24
D   -8 -20  -1   9 -22 -19  -3  -7  -8 -19 -22 -15 -22 -23 -19 -11 -13 -23 -11  -9   7  -4  -7 -24
C  -15 -12 -15 -22  11 -23 -23 -10 -13 -19 -15 -21 -22  -3 -20  -5 -10  -7  -4 -12 -17 -23  -9 -24
Q  -17  -6 -11 -19 -23   8  -7 -17  -4 -20  -8  -4 -13 -20  -5 -15 -13 -20 -15 -20 -12   6  -8 -24
E   -8 -15 -14  -3 -23  -7   8  -6 -15 -20 -23  -5 -14 -24 -20 -19 -13 -23 -17  -9  -5   6  -9 -24
G   -7  -6 -12  -7 -10 -17  -6   7 -19 -20 -22 -11 -21 -13 -20  -5 -12  -9 -22 -10  -8  -7  -9 -24
H  -16  -3  -4  -8 -13  -4 -15 -19  11 -16  -8 -14 -19 -13  -7 -12 -10 -17  -1 -22  -5  -6  -7 -24
I  -14 -11 -11 -19 -19 -20 -20 -20 -16   7  -4 -13  -3  -6 -17  -9  -3 -22 -15  -1 -12 -20  -7 -24
L  -14 -11 -20 -22 -15  -8 -23 -22  -8  -4   7 -16  -5  -3  -7 -10 -16 -10 -15  -8 -21 -11  -9 -24
K  -17  -1  -4 -15 -21  -4  -5 -11 -14 -13 -16   8  -9 -19 -17 -11  -5 -20 -22 -13  -6  -5  -6 -24
M  -16  -7 -19 -22 -22 -13 -14 -21 -19  -3  -5  -9  11 -13 -20 -18  -5 -16 -23  -4 -20 -14  -7 -24
F  -20 -21 -20 -23  -3 -20 -24 -13 -13  -6  -3 -19 -13  10 -19 -10 -18 -10  -2 -10 -21 -22  -8 -24
P   -7  -9 -17 -19 -20  -5 -20 -20  -7 -17  -7 -17 -20 -19   9  -5  -8 -18 -18 -20 -18  -8  -9 -24
S   -7  -6  -2 -11  -5 -15 -19  -5 -12  -9 -10 -11 -18 -10  -5   8  -3 -19 -11 -16  -4 -17  -7 -24
T   -2  -7  -4 -13 -10 -13 -13 -12 -10  -3 -16  -5  -5 -18  -8  -3   8 -23 -16 -10  -6 -13  -6 -24
W  -23 -10 -24 -23  -7 -20 -23  -9 -17 -22 -10 -20 -16 -10 -18 -19 -23  10  -9 -23 -23 -21 -12 -24
Y  -23 -18  -8 -11  -4 -15 -17 -22  -1 -15 -15 -22 -23  -2 -18 -11 -16  -9  10 -18  -9 -16  -9 -24
V   -4 -16 -18  -9 -12 -20  -9 -10 -22  -1  -8 -13  -4 -10 -20 -16 -10 -23 -18   8 -11 -11  -7 -24
B  -10 -14   7   7 -17 -12  -5  -8  -5 -12 -21  -6 -20 -21 -18  -4  -6 -23  -9 -11   8  -6  -8 -24
Z  -10  -8 -12  -4 -23   6   6  -7  -6 -20 -11  -5 -14 -22  -8 -17 -13 -21 -16 -11  -6   7  -9 -24
X   -8  -7  -7  -7  -9  -8  -9  -9  -7  -7  -9  -6  -7  -8  -9  -7  -6 -12  -9  -7  -8  -9  -8 -24
*  -24 -24 -24 -24 -24 -24 -24 -24 -24 -24 -24 -24 -24 -24 -24 -24 -24 -24 -24 -24 -24 -24 -24   1
*/
	scoreMatrix = 
		{
		{                 8,               -13,               -16,                -8,               -15,               -17,                -8,                -7,               -16,               -14,               -14,               -17,               -16,               -20,                -7,                -7,                -2,               -23,               -23,                -4,               -10,               -10,                -8,               -24}
		{               -13,                 8,               -12,               -20,               -12,                -6,               -15,                -6,                -3,               -11,               -11,                -1,                -7,               -21,                -9,                -6,                -7,               -10,               -18,               -16,               -14,                -8,                -7,               -24}
		{               -16,               -12,                 9,                -1,               -15,               -11,               -14,               -12,                -4,               -11,               -20,                -4,               -19,               -20,               -17,                -2,                -4,               -24,                -8,               -18,                 7,               -12,                -7,               -24}
		{                -8,               -20,                -1,                 9,               -22,               -19,                -3,                -7,                -8,               -19,               -22,               -15,               -22,               -23,               -19,               -11,               -13,               -23,               -11,                -9,                 7,                -4,                -7,               -24}
		{               -15,               -12,               -15,               -22,                11,               -23,               -23,               -10,               -13,               -19,               -15,               -21,               -22,                -3,               -20,                -5,               -10,                -7,                -4,               -12,               -17,               -23,                -9,               -24}
		{               -17,                -6,               -11,               -19,               -23,                 8,                -7,               -17,                -4,               -20,                -8,                -4,               -13,               -20,                -5,               -15,               -13,               -20,               -15,               -20,               -12,                 6,                -8,               -24}
		{                -8,               -15,               -14,                -3,               -23,                -7,                 8,                -6,               -15,               -20,               -23,                -5,               -14,               -24,               -20,               -19,               -13,               -23,               -17,                -9,                -5,                 6,                -9,               -24}
		{                -7,                -6,               -12,                -7,               -10,               -17,                -6,                 7,               -19,               -20,               -22,               -11,               -21,               -13,               -20,                -5,               -12,                -9,               -22,               -10,                -8,                -7,                -9,               -24}
		{               -16,                -3,                -4,                -8,               -13,                -4,               -15,               -19,                11,               -16,                -8,               -14,               -19,               -13,                -7,               -12,               -10,               -17,                -1,               -22,                -5,                -6,                -7,               -24}
		{               -14,               -11,               -11,               -19,               -19,               -20,               -20,               -20,               -16,                 7,                -4,               -13,                -3,                -6,               -17,                -9,                -3,               -22,               -15,                -1,               -12,               -20,                -7,               -24}
		{               -14,               -11,               -20,               -22,               -15,                -8,               -23,               -22,                -8,                -4,                 7,               -16,                -5,                -3,                -7,               -10,               -16,               -10,               -15,                -8,               -21,               -11,                -9,               -24}
		{               -17,                -1,                -4,               -15,               -21,                -4,                -5,               -11,               -14,               -13,               -16,                 8,                -9,               -19,               -17,               -11,                -5,               -20,               -22,               -13,                -6,                -5,                -6,               -24}
		{               -16,                -7,               -19,               -22,               -22,               -13,               -14,               -21,               -19,                -3,                -5,                -9,                11,               -13,               -20,               -18,                -5,               -16,               -23,                -4,               -20,               -14,                -7,               -24}
		{               -20,               -21,               -20,               -23,                -3,               -20,               -24,               -13,               -13,                -6,                -3,               -19,               -13,                10,               -19,               -10,               -18,               -10,                -2,               -10,               -21,               -22,                -8,               -24}
		{                -7,                -9,               -17,               -19,               -20,                -5,               -20,               -20,                -7,               -17,                -7,               -17,               -20,               -19,                 9,                -5,                -8,               -18,               -18,               -20,               -18,                -8,                -9,               -24}
		{                -7,                -6,                -2,               -11,                -5,               -15,               -19,                -5,               -12,                -9,               -10,               -11,               -18,               -10,                -5,                 8,                -3,               -19,               -11,               -16,                -4,               -17,                -7,               -24}
		{                -2,                -7,                -4,               -13,               -10,               -13,               -13,               -12,               -10,                -3,               -16,                -5,                -5,               -18,                -8,                -3,                 8,               -23,               -16,               -10,                -6,               -13,                -6,               -24}
		{               -23,               -10,               -24,               -23,                -7,               -20,               -23,                -9,               -17,               -22,               -10,               -20,               -16,               -10,               -18,               -19,               -23,                10,                -9,               -23,               -23,               -21,               -12,               -24}
		{               -23,               -18,                -8,               -11,                -4,               -15,               -17,               -22,                -1,               -15,               -15,               -22,               -23,                -2,               -18,               -11,               -16,                -9,                10,               -18,                -9,               -16,                -9,               -24}
		{                -4,               -16,               -18,                -9,               -12,               -20,                -9,               -10,               -22,                -1,                -8,               -13,                -4,               -10,               -20,               -16,               -10,               -23,               -18,                 8,               -11,               -11,                -7,               -24}
		{               -10,               -14,                 7,                 7,               -17,               -12,                -5,                -8,                -5,               -12,               -21,                -6,               -20,               -21,               -18,                -4,                -6,               -23,                -9,               -11,                 8,                -6,                -8,               -24}
		{               -10,                -8,               -12,                -4,               -23,                 6,                 6,                -7,                -6,               -20,               -11,                -5,               -14,               -22,                -8,               -17,               -13,               -21,               -16,               -11,                -6,                 7,                -9,               -24}
		{                -8,                -7,                -7,                -7,                -9,                -8,                -9,                -9,                -7,                -7,                -9,                -6,                -7,                -8,                -9,                -7,                -6,               -12,                -9,                -7,                -8,                -9,                -8,               -24}
		{               -24,               -24,               -24,               -24,               -24,               -24,               -24,               -24,               -24,               -24,               -24,               -24,               -24,               -24,               -24,               -24,               -24,               -24,               -24,               -24,               -24,               -24,               -24,                 1}
		};

}

if (refSeq == 2)
{

// HIV-1 between 25%
/*
# Divergence level: 0.25
# Matrix from: TeraMonkey:Users:sergei:hyphy:trunk:TemplateBatchFiles:TemplateModels:EmpiricalAA:HIVBetween
# Expected score: -1.40621 Entropy: 5.90658 bits
     A   R   N   D   C   Q   E   G   H   I   L   K   M   F   P   S   T   W   Y   V   B   Z   X   *
A    7  -7  -7  -4 -10 -11  -4  -3 -10  -6  -9  -9  -7 -13  -3  -2   1 -16 -15   0  -5  -5  -3 -17
R   -7   7  -5 -11  -8  -2  -7  -2   0  -6  -6   2  -3 -12  -4  -2  -2  -5  -9 -10  -7  -3  -3 -17
N   -7  -5   8   2  -9  -6  -6  -7   0  -6 -12   0 -10 -12  -9   1   0 -17  -3 -10   6  -6  -3 -17
D   -4 -11   2   8 -14 -10   0  -2  -3 -11 -15  -7 -13 -15 -13  -5  -6 -16  -6  -5   7   0  -3 -17
C  -10  -8  -9 -14  11 -16 -15  -5  -7 -11  -9 -13 -14   0 -12  -1  -6  -2   0  -8 -10 -16  -5 -17
Q  -11  -2  -6 -10 -16   8  -2 -10   0 -12  -4   0  -8 -12  -1  -9  -8 -14  -9 -13  -7   6  -4 -17
E   -4  -7  -6   0 -15  -2   7  -1  -9 -12 -15  -1 -10 -17 -13 -11  -8 -15 -12  -5   0   6  -4 -17
G   -3  -2  -7  -2  -5 -10  -1   7 -10 -11 -14  -6 -12  -9 -11  -1  -7  -5 -14  -5  -4  -3  -4 -17
H  -10   0   0  -3  -7   0  -9 -10  10 -10  -4  -5 -10  -6  -3  -6  -6 -11   2 -14  -1  -2  -3 -17
I   -6  -6  -6 -11 -11 -12 -12 -11 -10   7   0  -7   0  -2 -10  -4   0 -14  -9   2  -7 -12  -2 -17
L   -9  -6 -12 -15  -9  -4 -15 -14  -4   0   6 -10   0   0  -3  -5  -8  -6  -8  -4 -13  -6  -4 -17
K   -9   2   0  -7 -13   0  -1  -6  -5  -7 -10   7  -4 -14  -9  -5  -1 -12 -13  -9  -1  -1  -2 -17
M   -7  -3 -10 -13 -14  -8 -10 -12 -10   0   0  -4  10  -7 -11  -9  -1 -11 -15   0 -11  -9  -3 -17
F  -13 -12 -12 -15   0 -12 -17  -9  -6  -2   0 -14  -7  10 -11  -5 -10  -5   1  -5 -13 -14  -3 -17
P   -3  -4  -9 -13 -12  -1 -13 -11  -3 -10  -3  -9 -11 -11   8  -1  -3 -13 -11 -12 -10  -3  -5 -17
S   -2  -2   1  -5  -1  -9 -11  -1  -6  -4  -5  -5  -9  -5  -1   8   0 -12  -6  -9   0 -10  -3 -17
T    1  -2   0  -6  -6  -8  -8  -7  -6   0  -8  -1  -1 -10  -3   0   7 -16 -10  -4  -2  -8  -2 -17
W  -16  -5 -17 -16  -2 -14 -15  -5 -11 -14  -6 -12 -11  -5 -13 -12 -16  10  -4 -16 -16 -14  -8 -17
Y  -15  -9  -3  -6   0  -9 -12 -14   2  -9  -8 -13 -15   1 -11  -6 -10  -4  10 -12  -4 -10  -4 -17
V    0 -10 -10  -5  -8 -13  -5  -5 -14   2  -4  -9   0  -5 -12  -9  -4 -16 -12   7  -7  -7  -3 -17
B   -5  -7   6   7 -10  -7   0  -4  -1  -7 -13  -1 -11 -13 -10   0  -2 -16  -4  -7   7  -2  -4 -17
Z   -5  -3  -6   0 -16   6   6  -3  -2 -12  -6  -1  -9 -14  -3 -10  -8 -14 -10  -7  -2   6  -4 -17
X   -3  -3  -3  -3  -5  -4  -4  -4  -3  -2  -4  -2  -3  -3  -5  -3  -2  -8  -4  -3  -4  -4  -3 -17
*  -17 -17 -17 -17 -17 -17 -17 -17 -17 -17 -17 -17 -17 -17 -17 -17 -17 -17 -17 -17 -17 -17 -17   1

*/
	scoreMatrix = 
	{
	{                 7,                -7,                -7,                -4,               -10,               -11,                -4,                -3,               -10,                -6,                -9,                -9,                -7,               -13,                -3,                -2,                 1,               -16,               -15,                 0,                -5,                -5,                -3,               -17}
	{                -7,                 7,                -5,               -11,                -8,                -2,                -7,                -2,                 0,                -6,                -6,                 2,                -3,               -12,                -4,                -2,                -2,                -5,                -9,               -10,                -7,                -3,                -3,               -17}
	{                -7,                -5,                 8,                 2,                -9,                -6,                -6,                -7,                 0,                -6,               -12,                 0,               -10,               -12,                -9,                 1,                 0,               -17,                -3,               -10,                 6,                -6,                -3,               -17}
	{                -4,               -11,                 2,                 8,               -14,               -10,                 0,                -2,                -3,               -11,               -15,                -7,               -13,               -15,               -13,                -5,                -6,               -16,                -6,                -5,                 7,                 0,                -3,               -17}
	{               -10,                -8,                -9,               -14,                11,               -16,               -15,                -5,                -7,               -11,                -9,               -13,               -14,                 0,               -12,                -1,                -6,                -2,                 0,                -8,               -10,               -16,                -5,               -17}
	{               -11,                -2,                -6,               -10,               -16,                 8,                -2,               -10,                 0,               -12,                -4,                 0,                -8,               -12,                -1,                -9,                -8,               -14,                -9,               -13,                -7,                 6,                -4,               -17}
	{                -4,                -7,                -6,                 0,               -15,                -2,                 7,                -1,                -9,               -12,               -15,                -1,               -10,               -17,               -13,               -11,                -8,               -15,               -12,                -5,                 0,                 6,                -4,               -17}
	{                -3,                -2,                -7,                -2,                -5,               -10,                -1,                 7,               -10,               -11,               -14,                -6,               -12,                -9,               -11,                -1,                -7,                -5,               -14,                -5,                -4,                -3,                -4,               -17}
	{               -10,                 0,                 0,                -3,                -7,                 0,                -9,               -10,                10,               -10,                -4,                -5,               -10,                -6,                -3,                -6,                -6,               -11,                 2,               -14,                -1,                -2,                -3,               -17}
	{                -6,                -6,                -6,               -11,               -11,               -12,               -12,               -11,               -10,                 7,                 0,                -7,                 0,                -2,               -10,                -4,                 0,               -14,                -9,                 2,                -7,               -12,                -2,               -17}
	{                -9,                -6,               -12,               -15,                -9,                -4,               -15,               -14,                -4,                 0,                 6,               -10,                 0,                 0,                -3,                -5,                -8,                -6,                -8,                -4,               -13,                -6,                -4,               -17}
	{                -9,                 2,                 0,                -7,               -13,                 0,                -1,                -6,                -5,                -7,               -10,                 7,                -4,               -14,                -9,                -5,                -1,               -12,               -13,                -9,                -1,                -1,                -2,               -17}
	{                -7,                -3,               -10,               -13,               -14,                -8,               -10,               -12,               -10,                 0,                 0,                -4,                10,                -7,               -11,                -9,                -1,               -11,               -15,                 0,               -11,                -9,                -3,               -17}
	{               -13,               -12,               -12,               -15,                 0,               -12,               -17,                -9,                -6,                -2,                 0,               -14,                -7,                10,               -11,                -5,               -10,                -5,                 1,                -5,               -13,               -14,                -3,               -17}
	{                -3,                -4,                -9,               -13,               -12,                -1,               -13,               -11,                -3,               -10,                -3,                -9,               -11,               -11,                 8,                -1,                -3,               -13,               -11,               -12,               -10,                -3,                -5,               -17}
	{                -2,                -2,                 1,                -5,                -1,                -9,               -11,                -1,                -6,                -4,                -5,                -5,                -9,                -5,                -1,                 8,                 0,               -12,                -6,                -9,                 0,               -10,                -3,               -17}
	{                 1,                -2,                 0,                -6,                -6,                -8,                -8,                -7,                -6,                 0,                -8,                -1,                -1,               -10,                -3,                 0,                 7,               -16,               -10,                -4,                -2,                -8,                -2,               -17}
	{               -16,                -5,               -17,               -16,                -2,               -14,               -15,                -5,               -11,               -14,                -6,               -12,               -11,                -5,               -13,               -12,               -16,                10,                -4,               -16,               -16,               -14,                -8,               -17}
	{               -15,                -9,                -3,                -6,                 0,                -9,               -12,               -14,                 2,                -9,                -8,               -13,               -15,                 1,               -11,                -6,               -10,                -4,                10,               -12,                -4,               -10,                -4,               -17}
	{                 0,               -10,               -10,                -5,                -8,               -13,                -5,                -5,               -14,                 2,                -4,                -9,                 0,                -5,               -12,                -9,                -4,               -16,               -12,                 7,                -7,                -7,                -3,               -17}
	{                -5,                -7,                 6,                 7,               -10,                -7,                 0,                -4,                -1,                -7,               -13,                -1,               -11,               -13,               -10,                 0,                -2,               -16,                -4,                -7,                 7,                -2,                -4,               -17}
	{                -5,                -3,                -6,                 0,               -16,                 6,                 6,                -3,                -2,               -12,                -6,                -1,                -9,               -14,                -3,               -10,                -8,               -14,               -10,                -7,                -2,                 6,                -4,               -17}
	{                -3,                -3,                -3,                -3,                -5,                -4,                -4,                -4,                -3,                -2,                -4,                -2,                -3,                -3,                -5,                -3,                -2,                -8,                -4,                -3,                -4,                -4,                -3,               -17}
	{               -17,               -17,               -17,               -17,               -17,               -17,               -17,               -17,               -17,               -17,               -17,               -17,               -17,               -17,               -17,               -17,               -17,               -17,               -17,               -17,               -17,               -17,               -17,                 1}
	};


}

if (refSeq == 3)
{
/*
# Divergence level: 0.5
# Matrix from: TeraMonkey:Users:sergei:hyphy:trunk:TemplateBatchFiles:TemplateModels:EmpiricalAA:HIVBetween
# Expected score: -0.849814 Entropy: 4.53171 bits
     A   R   N   D   C   Q   E   G   H   I   L   K   M   F   P   S   T   W   Y   V   B   Z   X   *
A    7  -5  -4  -2  -7  -8  -2  -1  -8  -2  -6  -5  -4  -9  -1  -1   2 -13 -12   1  -3  -4  -2 -13
R   -5   6  -2  -7  -6   0  -4   0   1  -4  -4   3  -1  -9  -3   0  -1  -4  -6  -7  -4  -1  -1 -13
N   -4  -2   7   3  -6  -3  -3  -4   0  -4  -8   0  -7  -8  -5   2   0 -13  -2  -7   6  -3  -1 -13
D   -2  -7   3   8 -10  -6   2  -1  -1  -8 -12  -4 -10 -11  -9  -2  -4 -12  -4  -4   6   0  -2 -13
C   -7  -6  -6 -10  11 -12 -12  -3  -4  -7  -6  -9 -10   2  -8   0  -4   0   1  -6  -7 -12  -3 -13
Q   -8   0  -3  -6 -12   7  -1  -7   1  -8  -2   0  -6  -8   0  -6  -5 -11  -6 -10  -5   5  -2 -13
E   -2  -4  -3   2 -12  -1   7   0  -6  -8 -11   0  -7 -13  -9  -7  -5 -12  -9  -3   0   5  -2 -13
G   -1   0  -4  -1  -3  -7   0   7  -7  -8 -10  -3  -9  -7  -8   0  -4  -3 -10  -4  -2  -1  -3 -13
H   -8   1   0  -1  -4   1  -6  -7   9  -7  -2  -2  -7  -3  -1  -3  -4  -8   3 -10   0  -1  -1 -13
I   -2  -4  -4  -8  -7  -8  -8  -8  -7   6   0  -5   2   0  -7  -3   0 -11  -7   3  -5  -8  -1 -13
L   -6  -4  -8 -12  -6  -2 -11 -10  -2   0   6  -7   0   1  -1  -4  -5  -4  -5  -1 -10  -5  -3 -13
K   -5   3   0  -4  -9   0   0  -3  -2  -5  -7   6  -3 -11  -6  -2   0  -9  -9  -6   0   0  -1 -13
M   -4  -1  -7 -10 -10  -6  -7  -9  -7   2   0  -3  10  -4  -7  -6   0  -9 -10   1  -8  -6  -1 -13
F   -9  -9  -8 -11   2  -8 -13  -7  -3   0   1 -11  -4   9  -7  -4  -7  -3   3  -3  -9 -10  -2 -13
P   -1  -3  -5  -9  -8   0  -9  -8  -1  -7  -1  -6  -7  -7   8   0  -1 -11  -8  -8  -7  -2  -3 -13
S   -1   0   2  -2   0  -6  -7   0  -3  -3  -4  -2  -6  -4   0   7   1  -9  -4  -6   0  -6  -1 -13
T    2  -1   0  -4  -4  -5  -5  -4  -4   0  -5   0   0  -7  -1   1   6 -12  -7  -1   0  -5  -1 -13
W  -13  -4 -13 -12   0 -11 -12  -3  -8 -11  -4  -9  -9  -3 -11  -9 -12  10  -2 -12 -12 -11  -6 -13
Y  -12  -6  -2  -4   1  -6  -9 -10   3  -7  -5  -9 -10   3  -8  -4  -7  -2   9  -9  -3  -7  -3 -13
V    1  -7  -7  -4  -6 -10  -3  -4 -10   3  -1  -6   1  -3  -8  -6  -1 -12  -9   6  -5  -5  -1 -13
B   -3  -4   6   6  -7  -5   0  -2   0  -5 -10   0  -8  -9  -7   0   0 -12  -3  -5   7   0  -2 -13
Z   -4  -1  -3   0 -12   5   5  -1  -1  -8  -5   0  -6 -10  -2  -6  -5 -11  -7  -5   0   6  -3 -13
X   -2  -1  -1  -2  -3  -2  -2  -3  -1  -1  -3  -1  -1  -2  -3  -1  -1  -6  -3  -1  -2  -3  -2 -13
*  -13 -13 -13 -13 -13 -13 -13 -13 -13 -13 -13 -13 -13 -13 -13 -13 -13 -13 -13 -13 -13 -13 -13   1

*/
	scoreMatrix = 
	{
	{                 7,                -5,                -4,                -2,                -7,                -8,                -2,                -1,                -8,                -2,                -6,                -5,                -4,                -9,                -1,                -1,                 2,               -13,               -12,                 1,                -3,                -4,                -2,               -13}
	{                -5,                 6,                -2,                -7,                -6,                 0,                -4,                 0,                 1,                -4,                -4,                 3,                -1,                -9,                -3,                 0,                -1,                -4,                -6,                -7,                -4,                -1,                -1,               -13}
	{                -4,                -2,                 7,                 3,                -6,                -3,                -3,                -4,                 0,                -4,                -8,                 0,                -7,                -8,                -5,                 2,                 0,               -13,                -2,                -7,                 6,                -3,                -1,               -13}
	{                -2,                -7,                 3,                 8,               -10,                -6,                 2,                -1,                -1,                -8,               -12,                -4,               -10,               -11,                -9,                -2,                -4,               -12,                -4,                -4,                 6,                 0,                -2,               -13}
	{                -7,                -6,                -6,               -10,                11,               -12,               -12,                -3,                -4,                -7,                -6,                -9,               -10,                 2,                -8,                 0,                -4,                 0,                 1,                -6,                -7,               -12,                -3,               -13}
	{                -8,                 0,                -3,                -6,               -12,                 7,                -1,                -7,                 1,                -8,                -2,                 0,                -6,                -8,                 0,                -6,                -5,               -11,                -6,               -10,                -5,                 5,                -2,               -13}
	{                -2,                -4,                -3,                 2,               -12,                -1,                 7,                 0,                -6,                -8,               -11,                 0,                -7,               -13,                -9,                -7,                -5,               -12,                -9,                -3,                 0,                 5,                -2,               -13}
	{                -1,                 0,                -4,                -1,                -3,                -7,                 0,                 7,                -7,                -8,               -10,                -3,                -9,                -7,                -8,                 0,                -4,                -3,               -10,                -4,                -2,                -1,                -3,               -13}
	{                -8,                 1,                 0,                -1,                -4,                 1,                -6,                -7,                 9,                -7,                -2,                -2,                -7,                -3,                -1,                -3,                -4,                -8,                 3,               -10,                 0,                -1,                -1,               -13}
	{                -2,                -4,                -4,                -8,                -7,                -8,                -8,                -8,                -7,                 6,                 0,                -5,                 2,                 0,                -7,                -3,                 0,               -11,                -7,                 3,                -5,                -8,                -1,               -13}
	{                -6,                -4,                -8,               -12,                -6,                -2,               -11,               -10,                -2,                 0,                 6,                -7,                 0,                 1,                -1,                -4,                -5,                -4,                -5,                -1,               -10,                -5,                -3,               -13}
	{                -5,                 3,                 0,                -4,                -9,                 0,                 0,                -3,                -2,                -5,                -7,                 6,                -3,               -11,                -6,                -2,                 0,                -9,                -9,                -6,                 0,                 0,                -1,               -13}
	{                -4,                -1,                -7,               -10,               -10,                -6,                -7,                -9,                -7,                 2,                 0,                -3,                10,                -4,                -7,                -6,                 0,                -9,               -10,                 1,                -8,                -6,                -1,               -13}
	{                -9,                -9,                -8,               -11,                 2,                -8,               -13,                -7,                -3,                 0,                 1,               -11,                -4,                 9,                -7,                -4,                -7,                -3,                 3,                -3,                -9,               -10,                -2,               -13}
	{                -1,                -3,                -5,                -9,                -8,                 0,                -9,                -8,                -1,                -7,                -1,                -6,                -7,                -7,                 8,                 0,                -1,               -11,                -8,                -8,                -7,                -2,                -3,               -13}
	{                -1,                 0,                 2,                -2,                 0,                -6,                -7,                 0,                -3,                -3,                -4,                -2,                -6,                -4,                 0,                 7,                 1,                -9,                -4,                -6,                 0,                -6,                -1,               -13}
	{                 2,                -1,                 0,                -4,                -4,                -5,                -5,                -4,                -4,                 0,                -5,                 0,                 0,                -7,                -1,                 1,                 6,               -12,                -7,                -1,                 0,                -5,                -1,               -13}
	{               -13,                -4,               -13,               -12,                 0,               -11,               -12,                -3,                -8,               -11,                -4,                -9,                -9,                -3,               -11,                -9,               -12,                10,                -2,               -12,               -12,               -11,                -6,               -13}
	{               -12,                -6,                -2,                -4,                 1,                -6,                -9,               -10,                 3,                -7,                -5,                -9,               -10,                 3,                -8,                -4,                -7,                -2,                 9,                -9,                -3,                -7,                -3,               -13}
	{                 1,                -7,                -7,                -4,                -6,               -10,                -3,                -4,               -10,                 3,                -1,                -6,                 1,                -3,                -8,                -6,                -1,               -12,                -9,                 6,                -5,                -5,                -1,               -13}
	{                -3,                -4,                 6,                 6,                -7,                -5,                 0,                -2,                 0,                -5,               -10,                 0,                -8,                -9,                -7,                 0,                 0,               -12,                -3,                -5,                 7,                 0,                -2,               -13}
	{                -4,                -1,                -3,                 0,               -12,                 5,                 5,                -1,                -1,                -8,                -5,                 0,                -6,               -10,                -2,                -6,                -5,               -11,                -7,                -5,                 0,                 6,                -3,               -13}
	{                -2,                -1,                -1,                -2,                -3,                -2,                -2,                -3,                -1,                -1,                -3,                -1,                -1,                -2,                -3,                -1,                -1,                -6,                -3,                -1,                -2,                -3,                -2,               -13}
	{               -13,               -13,               -13,               -13,               -13,               -13,               -13,               -13,               -13,               -13,               -13,               -13,               -13,               -13,               -13,               -13,               -13,               -13,               -13,               -13,               -13,               -13,               -13,                 1}
	};

}


alignOptions ["SEQ_ALIGN_SCORE_MATRIX"] = 	scoreMatrix[{{0,0}}][{{19,19}}];
alignOptions ["SEQ_ALIGN_GAP_OPEN"]		= 	40;
alignOptions ["SEQ_ALIGN_GAP_OPEN2"]	= 	20;
alignOptions ["SEQ_ALIGN_GAP_EXTEND"]	= 	10;
alignOptions ["SEQ_ALIGN_GAP_EXTEND2"]	= 	5;
alignOptions ["SEQ_ALIGN_AFFINE"]		=   1;

ChoiceList (refSeq,"Prefix/Suffix Indels",1,SKIP_NONE,"No penalty","Do not penalize prefix and suffix Indels","Normal penalty","Treat prefix and suffix indels as any other indels");
if (refSeq < 0)
{
	return 0;
}

alignOptions ["SEQ_ALIGN_NO_TP"]		=   1-refSeq;

if (_skipPredefsSeqAlignShared == 0)
{
	predefSeqNames = {{"First in file", "Use the first sequence in the data file as a reference"}
					  {"Longest in file", "Use the longest sequence in the data file as the reference"}
					 /*0*/ {"HXB2_env", "Use HIV-1 HXB2 reference strain envelope sequence (K03455)"}
					 /*1*/ {"HXB2_nef", "Use HIV-1 HXB2 reference strain NEF sequence (K03455)"}
					 /*2*/ {"HXB2_gag", "Use HIV-1 HXB2 reference strain gag sequence (K03455)"} 
					 /*3*/ {"HXB2_vpr", "Use HIV-1 HXB2 reference strain vpr sequence (K03455)"} 
					 /*4*/ {"HXB2_vif", "Use HIV-1 HXB2 reference strain vif sequence (K03455)"} 
					 /*5*/ {"HXB2_vpu", "Use HIV-1 HXB2 reference strain vpu sequence (K03455)"} 
					 /*6*/ {"HXB2_pr", "Use HIV-1 HXB2 reference strain protease sequence (K03455)"} 
					 /*7*/ {"HXB2_rt", "Use HIV-1 HXB2 reference strain reverse transcriptase sequence (K03455)"} 
					 /*8*/ {"HXB2_int", "Use HIV-1 HXB2 reference strain integrase sequence (K03455)"} 
					 /*9*/ {"HXB2_rev", "Use HIV-1 HXB2 reference strain rev (exons 1 and 2)sequence (K03455)"} 
					/*10*/ {"HXB2_tat", "Use HIV-1 HXB2 reference strain tat (exons 1 and 2) sequence (K03455)"} 
					/*11*/ {"HXB2_prrt", "Use HIV-1 HXB2 reference strain protease+rt sequence (K03455)"}
					/*12*/ {"NL4_3prrt", "Use HIV-1 NL4-3 reference strain pr+rt sequence"} 
					/*13*/ {"HXB2_pol",  "Use HIV-1 HXB2 reference strain pol (starting at pr) sequence (K03455)"}
									  };
					  
					  
	predefSeqNames2 = {{"No", "No reference coordinate sequences"}
					 /*0*/ {"HXB2_env", "Use HIV-1 HXB2 reference strain envelope sequence (K03455)"}
					 /*1*/ {"HXB2_nef", "Use HIV-1 HXB2 reference strain NEF sequence (K03455)"}
					 /*2*/ {"HXB2_gag", "Use HIV-1 HXB2 reference strain gag sequence (K03455)"} 
					 /*3*/ {"HXB2_vpr", "Use HIV-1 HXB2 reference strain vpr sequence (K03455)"} 
					 /*4*/ {"HXB2_vif", "Use HIV-1 HXB2 reference strain vif sequence (K03455)"} 
					 /*5*/ {"HXB2_vpu", "Use HIV-1 HXB2 reference strain vpu sequence (K03455)"} 
					 /*6*/ {"HXB2_pr", "Use HIV-1 HXB2 reference strain protease sequence (K03455)"} 
					 /*7*/ {"HXB2_rt", "Use HIV-1 HXB2 reference strain reverse transcriptase sequence (K03455)"} 
					 /*8*/ {"HXB2_int", "Use HIV-1 HXB2 reference strain integrase sequence (K03455)"} 
					 /*9*/ {"HXB2_rev", "Use HIV-1 HXB2 reference strain rev (exons 1 and 2)sequence (K03455)"} 
					/*10*/ {"HXB2_tat", "Use HIV-1 HXB2 reference strain tat (exons 1 and 2) sequence (K03455)"} 
					/*11*/ {"HXB2_prrt", "Use HIV-1 HXB2 reference strain protease+rt sequence (K03455)"} 
					/*12*/ {"NL4_3prrt", "Use HIV-1 NL4-3 reference strain pr+rt sequence"} 
					/*13*/ {"HXB2_pol",  "Use HIV-1 HXB2 reference strain pol (starting at pr) sequence (K03455)"}
					  };
	
	RefSeqs = {};
	RefSeqs [0] = "ATGAGAGTGAAGGAGAAATATCAGCACTTGTGGAGATGGGGGTGGAGATGGGGCACCATGCTCCTTGGGATGTTGATGATCTGTAGTGCTACAGAAAAATTGTGGGTCACAGTCTATTATGGGGTACCTGTGTGGAAGGAAGCAACCACCACTCTATTTTGTGCATCAGATGCTAAAGCATATGATACAGAGGTACATAATGTTTGGGCCACACATGCCTGTGTACCCACAGACCCCAACCCACAAGAAGTAGTATTGGTAAATGTGACAGAAAATTTTAACATGTGGAAAAATGACATGGTAGAACAGATGCATGAGGATATAATCAGTTTATGGGATCAAAGCCTAAAGCCATGTGTAAAATTAACCCCACTCTGTGTTAGTTTAAAGTGCACTGATTTGAAGAATGATACTAATACCAATAGTAGTAGCGGGAGAATGATAATGGAGAAAGGAGAGATAAAAAACTGCTCTTTCAATATCAGCACAAGCATAAGAGGTAAGGTGCAGAAAGAATATGCATTTTTTTATAAACTTGATATAATACCAATAGATAATGATACTACCAGCTATAAGTTGACAAGTTGTAACACCTCAGTCATTACACAGGCCTGTCCAAAGGTATCCTTTGAGCCAATTCCCATACATTATTGTGCCCCGGCTGGTTTTGCGATTCTAAAATGTAATAATAAGACGTTCAATGGAACAGGACCATGTACAAATGTCAGCACAGTACAATGTACACATGGAATTAGGCCAGTAGTATCAACTCAACTGCTGTTAAATGGCAGTCTAGCAGAAGAAGAGGTAGTAATTAGATCTGTCAATTTCACGGACAATGCTAAAACCATAATAGTACAGCTGAACACATCTGTAGAAATTAATTGTACAAGACCCAACAACAATACAAGAAAAAGAATCCGTATCCAGAGAGGACCAGGGAGAGCATTTGTTACAATAGGAAAAATAGGAAATATGAGACAAGCACATTGTAACATTAGTAGAGCAAAATGGAATAACACTTTAAAACAGATAGCTAGCAAATTAAGAGAACAATTTGGAAATAATAAAACAATAATCTTTAAGCAATCCTCAGGAGGGGACCCAGAAATTGTAACGCACAGTTTTAATTGTGGAGGGGAATTTTTCTACTGTAATTCAACACAACTGTTTAATAGTACTTGGTTTAATAGTACTTGGAGTACTGAAGGGTCAAATAACACTGAAGGAAGTGACACAATCACCCTCCCATGCAGAATAAAACAAATTATAAACATGTGGCAGAAAGTAGGAAAAGCAATGTATGCCCCTCCCATCAGTGGACAAATTAGATGTTCATCAAATATTACAGGGCTGCTATTAACAAGAGATGGTGGTAATAGCAACAATGAGTCCGAGATCTTCAGACCTGGAGGAGGAGATATGAGGGACAATTGGAGAAGTGAATTATATAAATATAAAGTAGTAAAAATTGAACCATTAGGAGTAGCACCCACCAAGGCAAAGAGAAGAGTGGTGCAGAGAGAAAAAAGAGCAGTGGGAATAGGAGCTTTGTTCCTTGGGTTCTTGGGAGCAGCAGGAAGCACTATGGGCGCAGCCTCAATGACGCTGACGGTACAGGCCAGACAATTATTGTCTGGTATAGTGCAGCAGCAGAACAATTTGCTGAGGGCTATTGAGGCGCAACAGCATCTGTTGCAACTCACAGTCTGGGGCATCAAGCAGCTCCAGGCAAGAATCCTGGCTGTGGAAAGATACCTAAAGGATCAACAGCTCCTGGGGATTTGGGGTTGCTCTGGAAAACTCATTTGCACCACTGCTGTGCCTTGGAATGCTAGTTGGAGTAATAAATCTCTGGAACAGATTTGGAATCACACGACCTGGATGGAGTGGGACAGAGAAATTAACAATTACACAAGCTTAATACACTCCTTAATTGAAGAATCGCAAAACCAGCAAGAAAAGAATGAACAAGAATTATTGGAATTAGATAAATGGGCAAGTTTGTGGAATTGGTTTAACATAACAAATTGGCTGTGGTATATAAAATTATTCATAATGATAGTAGGAGGCTTGGTAGGTTTAAGAATAGTTTTTGCTGTACTTTCTATAGTGAATAGAGTTAGGCAGGGATATTCACCATTATCGTTTCAGACCCACCTCCCAACCCCGAGGGGACCCGACAGGCCCGAAGGAATAGAAGAAGAAGGTGGAGAGAGAGACAGAGACAGATCCATTCGATTGGTGAACGGATCCTTGGCACTTATCTGGGACGATCTGCGGAGCCTGTGCCTCTTCAGCTACCACCGCTTGAGAGACTTACTCTTGATTGTAACGAGGATTGTGGAACTTCTGGGACGCAGGGGGTGGGAAGCCCTCAAATATTGGTGGAATCTCCTACAGTATTGGAGTCAGGAACTAAAGAATAGTGCTGTTAGCTTGCTCAATGCCACAGCCATAGCAGTAGCTGAGGGGACAGATAGGGTTATAGAAGTAGTACAAGGAGCTTGTAGAGCTATTCGCCACATACCTAGAAGAATAAGACAGGGCTTGGAAAGGATTTTGCTA";
	RefSeqs [1] = "ATGGGTGGCAAGTGGTCAAAAAGTAGTGTGATTGGATGGCCTACTGTAAGGGAAAGAATGAGACGAGCTGAGCCAGCAGCAGATAGGGTGGGAGCAGCATCTCGAGACCTGGAAAAACATGGAGCAATCACAAGTAGCAATACAGCAGCTACCAATGCTGCTTGTGCCTGGCTAGAAGCACAAGAGGAGGAGGAGGTGGGTTTTCCAGTCACACCTCAGGTACCTTTAAGACCAATGACTTACAAGGCAGCTGTAGATCTTAGCCACTTTTTAAAAGAAAAGGGGGGACTGGAAGGGCTAATTCACTCCCAAAGAAGACAAGATATCCTTGATCTGTGGATCTACCACACACAAGGCTACTTCCCTGAT---CAGAACTACACACCAGGGCCAGGGGTCAGATATCCACTGACCTTTGGATGGTGCTACAAGCTAGTACCAGTTGAGCCAGATAAGATAGAAGAGGCCAATAAAGGAGAGAACACCAGCTTGTTACACCCTGTGAGCCTGCATGGGATGGATGACCCGGAGAGAGAAGTGTTAGAGTGGAGGTTTGACAGCCGCCTAGCATTTCATCACGTGGCCCGAGAGCTGCATCCGGAGTACTTCAAGAACTGC";
	RefSeqs [2] = "ATGGGTGCGAGAGCGTCAGTATTAAGCGGGGGAGAATTAGATCGATGGGAAAAAATTCGGTTAAGGCCAGGGGGAAAGAAAAAATATAAATTAAAACATATAGTATGGGCAAGCAGGGAGCTAGAACGATTCGCAGTTAATCCTGGCCTGTTAGAAACATCAGAAGGCTGTAGACAAATACTGGGACAGCTACAACCATCCCTTCAGACAGGATCAGAAGAACTTAGATCATTATATAATACAGTAGCAACCCTCTATTGTGTGCATCAAAGGATAGAGATAAAAGACACCAAGGAAGCTTTAGACAAGATAGAGGAAGAGCAAAACAAAAGTAAGAAAAAAGCACAGCAAGCAGCAGCTGACACAGGACACAGCAATCAGGTCAGCCAAAATTACCCTATAGTGCAGAACATCCAGGGGCAAATGGTACATCAGGCCATATCACCTAGAACTTTAAATGCATGGGTAAAAGTAGTAGAAGAGAAGGCTTTCAGCCCAGAAGTGATACCCATGTTTTCAGCATTATCAGAAGGAGCCACCCCACAAGATTTAAACACCATGCTAAACACAGTGGGGGGACATCAAGCAGCCATGCAAATGTTAAAAGAGACCATCAATGAGGAAGCTGCAGAATGGGATAGAGTGCATCCAGTGCATGCAGGGCCTATTGCACCAGGCCAGATGAGAGAACCAAGGGGAAGTGACATAGCAGGAACTACTAGTACCCTTCAGGAACAAATAGGATGGATGACAAATAATCCACCTATCCCAGTAGGAGAAATTTATAAAAGATGGATAATCCTGGGATTAAATAAAATAGTAAGAATGTATAGCCCTACCAGCATTCTGGACATAAGACAAGGACCAAAGGAACCCTTTAGAGACTATGTAGACCGGTTCTATAAAACTCTAAGAGCCGAGCAAGCTTCACAGGAGGTAAAAAATTGGATGACAGAAACCTTGTTGGTCCAAAATGCGAACCCAGATTGTAAGACTATTTTAAAAGCATTGGGACCAGCGGCTACACTAGAAGAAATGATGACAGCATGTCAGGGAGTAGGAGGACCCGGCCATAAGGCAAGAGTTTTGGCTGAAGCAATGAGCCAAGTAACAAATTCAGCTACCATAATGATGCAGAGAGGCAATTTTAGGAACCAAAGAAAGATTGTTAAGTGTTTCAATTGTGGCAAAGAAGGGCACACAGCCAGAAATTGCAGGGCCCCTAGGAAAAAGGGCTGTTGGAAATGTGGAAAGGAAGGACACCAAATGAAAGATTGTACTGAGAGACAGGCTAATTTTTTAGGGAAGATCTGGCCTTCCTACAAGGGAAGGCCAGGGAATTTTCTTCAGAGCAGACCAGAGCCAACAGCCCCACCAGAAGAGAGCTTCAGGTCTGGGGTAGAGACAACAACTCCCCCTCAGAAGCAGGAGCCGATAGACAAGGAACTGTATCCTTTAACTTCCCTCAGGTCACTCTTTGGCAACGACCCCTCGTCACAA";				  
	RefSeqs [3] = "ATGGAACAAGCCCCAGAAGACCAAGGGCCACAGAGGGAGCCACACAATGAATGGACACTAGAGCTTTTAGAGGAGCTTAAGAATGAAGCTGTTAGACATTTTCCTAGGATTTGGCTCCATGGCTTAGGGCAACATATCTATGAAACTTATGGGGATACTTGGGCAGGAGTGGAAGCCATAATAAGAATTCTGCAACAACTGCTGTTTATCCATTTTCAGAATTGGGTGTCGACA---CAGAATAGGCGTTACTCGACAGAGGAGAGCAAGAAATGGAGCCAG---ATC";				  
	RefSeqs [4] = "ATGGAAAACAGATGGCAGGTGATGATTGTGTGGCAAGTAGACAGGATGAGGATTAGAACATGGAAAAGTTTAGTAAAACACCATATGTATGTTTCAGGGAAAGCTAGGGGATGGTTTTATAGACATCACTATGAAAGCCCTCATCCAAGAATAAGTTCAGAAGTACACATCCCACTAGGGGATGCTAGATTGGTAATAACAACATATTGGGGTCTGCATACAGGAGAAAGAGACTGGCATTTGGGTCAGGGAGTCTCCATAGAATGGAGGAAAAAGAGATATAGCACACAAGTAGACCCTGAACTAGCAGACCAACTAATTCATCTGTATTACTTTGACTGTTTTTCAGACTCTGCTATAAGAAAGGCCTTATTAGGACACATAGTTAGCCCTAGGTGTGAATATCAAGCAGGACATAACAAGGTAGGATCTCTACAATACTTGGCACTAGCAGCATTAATAACACCAAAAAAGATAAAGCCACCTTTGCCTAGTGTTACGAAACTGACAGAGGATAGATGGAACAAGCCCCAGAAGACCAAGGGCCACAGAGGGAGCCACACAATGAATGGACAC";				  
	RefSeqs [5] = "ACGCAACCTATACCAATAGTAGCAATAGTAGCATTAGTAGTAGCAATAATAATAGCAATAGTTGTGTGGTCCATAGTAATCATAGAATATAGGAAAATATTAAGACAAAGAAAAATAGACAGGTTAATTGATAGACTAATAGAAAGAGCAGAAGACAGTGGCAATGAGAGTGAAGGAGAAATATCAGCACTTGTGGAGATGGGGGTGGAGATGGGGCACCATGCTCCTTGGGATGTTGATGATC";				  
	RefSeqs [6] = "CCTCAGGTCACTCTTTGGCAACGACCCCTCGTCACAATAAAGATAGGGGGGCAACTAAAGGAAGCTCTATTAGATACAGGAGCAGATGATACAGTATTAGAAGAAATGAGTTTGCCAGGAAGATGGAAACCAAAAATGATAGGGGGAATTGGAGGTTTTATCAAAGTAAGACAGTATGATCAGATACTCATAGAAATCTGTGGACATAAAGCTATAGGTACAGTATTAGTAGGACCTACACCTGTCAACATAATTGGAAGAAATCTGTTGACTCAGATTGGTTGCACTTTAAATTTT";				  
	RefSeqs [7] = "CCCATTAGCCCTATTGAGACTGTACCAGTAAAATTAAAGCCAGGAATGGATGGCCCAAAAGTTAAACAATGGCCATTGACAGAAGAAAAAATAAAAGCATTAGTAGAAATTTGTACAGAGATGGAAAAGGAAGGGAAAATTTCAAAAATTGGGCCTGAAAATCCATACAATACTCCAGTATTTGCCATAAAGAAAAAAGACAGTACTAAATGGAGAAAATTAGTAGATTTCAGAGAACTTAATAAGAGAACTCAAGACTTCTGGGAAGTTCAATTAGGAATACCACATCCCGCAGGGTTAAAAAAGAAAAAATCAGTAACAGTACTGGATGTGGGTGATGCATATTTTTCAGTTCCCTTAGATGAAGACTTCAGGAAGTATACTGCATTTACCATACCTAGTATAAACAATGAGACACCAGGGATTAGATATCAGTACAATGTGCTTCCACAGGGATGGAAAGGATCACCAGCAATATTCCAAAGTAGCATGACAAAAATCTTAGAGCCTTTTAGAAAACAAAATCCAGACATAGTTATCTATCAATACATGGATGATTTGTATGTAGGATCTGACTTAGAAATAGGGCAGCATAGAACAAAAATAGAGGAGCTGAGACAACATCTGTTGAGGTGGGGACTTACCACACCAGACAAAAAACATCAGAAAGAACCTCCATTCCTTTGGATGGGTTATGAACTCCATCCTGATAAATGGACAGTACAGCCTATAGTGCTGCCAGAAAAAGACAGCTGGACTGTCAATGACATACAGAAGTTAGTGGGGAAATTGAATTGGGCAAGTCAGATTTACCCAGGGATTAAAGTAAGGCAATTATGTAAACTCCTTAGAGGAACCAAAGCACTAACAGAAGTAATACCACTAACAGAAGAAGCAGAGCTAGAACTGGCAGAAAACAGAGAGATTCTAAAAGAACCAGTACATGGAGTGTATTATGACCCATCAAAAGACTTAATAGCAGAAATACAGAAGCAGGGGCAAGGCCAATGGACATATCAAATTTATCAAGAGCCATTTAAAAATCTGAAAACAGGAAAATATGCAAGAATGAGGGGTGCCCACACTAATGATGTAAAACAATTAACAGAGGCAGTGCAAAAAATAACCACAGAAAGCATAGTAATATGGGGAAAGACTCCTAAATTTAAACTGCCCATACAAAAGGAAACATGGGAAACATGGTGGACAGAGTATTGGCAAGCCACCTGGATTCCTGAGTGGGAGTTTGTTAATACCCCTCCCTTAGTGAAATTATGGTACCAGTTAGAGAAAGAACCCATAGTAGGAGCAGAAACCTTC";				  
	RefSeqs [8] = "TTTTTAGATGGAATAGATAAGGCCCAAGATGAACATGAGAAATATCACAGTAATTGGAGAGCAATGGCTAGTGATTTTAACCTGCCACCTGTAGTAGCAAAAGAAATAGTAGCCAGCTGTGATAAATGTCAGCTAAAAGGAGAAGCCATGCATGGACAAGTAGACTGTAGTCCAGGAATATGGCAACTAGATTGTACACATTTAGAAGGAAAAGTTATCCTGGTAGCAGTTCATGTAGCCAGTGGATATATAGAAGCAGAAGTTATTCCAGCAGAAACAGGGCAGGAAACAGCATATTTTCTTTTAAAATTAGCAGGAAGATGGCCAGTAAAAACAATACATACTGACAATGGCAGCAATTTCACCGGTGCTACGGTTAGGGCCGCCTGTTGGTGGGCGGGAATCAAGCAGGAATTTGGAATTCCCTACAATCCCCAAAGTCAAGGAGTAGTAGAATCTATGAATAAAGAATTAAAGAAAATTATAGGACAGGTAAGAGATCAGGCTGAACATCTTAAGACAGCAGTACAAATGGCAGTATTCATCCACAATTTTAAAAGAAAAGGGGGGATTGGGGGGTACAGTGCAGGGGAAAGAATAGTAGACATAATAGCAACAGACATACAAACTAAAGAATTACAAAAACAAATTACAAAAATTCAAAATTTTCGGGTTTATTACAGGGACAGCAGAAATCCACTTTGGAAAGGACCAGCAAAGCTCCTCTGGAAAGGTGAAGGGGCAGTAGTAATACAAGATAATAGTGACATAAAAGTAGTGCCAAGAAGAAAAGCAAAGATCATTAGGGATTATGGAAAACAGATGGCAGGTGATGATTGTGTGGCAAGTAGACAGGATGAGGAT";
	RefSeqs [9] = "ATGGCAGGAAGAAGCGGAGACAGCGACGAAGAGCTCATCAGAACAGTCAGACTCATCAAGCTTCTCTAACCCACCTCCCAACCCCGAGGGGACCCGACAGGCCCGAAGGAATAGAAGAAGAAGGTGGAGAGAGAGACAGAGACAGATCCATTCGATTAGTGAACGGATCCTTGGCACTTATCTGGGACGATCTGCGGAGCCTGTGCCTCTTCAGCTACCACCGCTTGAGAGACTTACTCTTGATTGTAACGAGGATTGTGGAACTTCTGGGACGCAGGGGGTGGGAAGCCCTCAAATATTGGTGGAATCTCCTACAGTATTGGAGTCAGGAACTAAAGA";
	RefSeqs[10] = "ATGGAGCCAGTAGATCCTAGACTAGAGCCCTGGAAGCATCCAGGAAGTCAGCCTAAAACTGCTTGTACCAATTGCTATTGTAAAAAGTGTTGCTTTCATTGCCAAGTTTGTTTCATAACAAAAGCCTTAGGCATCTCCTATGGCAGGAAGAAGCGGAGACAGCGACGAAGAGCTCATCAGAACAGTCAGACTCATCAAGCTTCTCTATCAAAGCAACCCACCTCCCAACCCCGAGGGGACCCGACAGGCCCGAAGGAATAGAAGAAGAAGGTGGAGAGAGAGACAGAGACAGATCCATTCGAT";
	RefSeqs[11] = "CCTCAGGTCACTCTTTGGCAACGACCCCTCGTCACAATAAAGATAGGGGGGCAACTAAAGGAAGCTCTATTAGATACAGGAGCAGATGATACAGTATTAGAAGAAATGAGTTTGCCAGGAAGATGGAAACCAAAAATGATAGGGGGAATTGGAGGTTTTATCAAAGTAAGACAGTATGATCAGATACTCATAGAAATCTGTGGACATAAAGCTATAGGTACAGTATTAGTAGGACCTACACCTGTCAACATAATTGGAAGAAATCTGTTGACTCAGATTGGTTGCACTTTAAATTTTCCCATTAGCCCTATTGAGACTGTACCAGTAAAATTAAAGCCAGGAATGGATGGCCCAAAAGTTAAACAATGGCCATTGACAGAAGAAAAAATAAAAGCATTAGTAGAAATTTGTACAGAGATGGAAAAGGAAGGGAAAATTTCAAAAATTGGGCCTGAAAATCCATACAATACTCCAGTATTTGCCATAAAGAAAAAAGACAGTACTAAATGGAGAAAATTAGTAGATTTCAGAGAACTTAATAAGAGAACTCAAGACTTCTGGGAAGTTCAATTAGGAATACCACATCCCGCAGGGTTAAAAAAGAAAAAATCAGTAACAGTACTGGATGTGGGTGATGCATATTTTTCAGTTCCCTTAGATGAAGACTTCAGGAAGTATACTGCATTTACCATACCTAGTATAAACAATGAGACACCAGGGATTAGATATCAGTACAATGTGCTTCCACAGGGATGGAAAGGATCACCAGCAATATTCCAAAGTAGCATGACAAAAATCTTAGAGCCTTTTAGAAAACAAAATCCAGACATAGTTATCTATCAATACATGGATGATTTGTATGTAGGATCTGACTTAGAAATAGGGCAGCATAGAACAAAAATAGAGGAGCTGAGACAACATCTGTTGAGGTGGGGACTTACCACACCAGACAAAAAACATCAGAAAGAACCTCCATTCCTTTGGATGGGTTATGAACTCCATCCTGATAAATGGACAGTACAGCCTATAGTGCTGCCAGAAAAAGACAGCTGGACTGTCAATGACATACAGAAGTTAGTGGGGAAATTGAATTGGGCAAGTCAGATTTACCCAGGGATTAAAGTAAGGCAATTATGTAAACTCCTTAGAGGAACCAAAGCACTAACAGAAGTAATACCACTAACAGAAGAAGCAGAGCTAGAACTGGCAGAAAACAGAGAGATTCTAAAAGAACCAGTACATGGAGTGTATTATGACCCATCAAAAGACTTAATAGCAGAAATACAGAAGCAGGGGCAAGGCCAATGGACATATCAAATTTATCAAGAGCCATTTAAAAATCTGAAAACAGGAAAATATGCAAGAATGAGGGGTGCCCACACTAATGATGTAAAACAATTAACAGAGGCAGTGCAAAAAATAACCACAGAAAGCATAGTAATATGGGGAAAGACTCCTAAATTTAAACTGCCCATACAAAAGGAAACATGGGAAACATGGTGGACAGAGTATTGGCAAGCCACCTGGATTCCTGAGTGGGAGTTTGTTAATACCCCTCCCTTAGTGAAATTATGGTACCAGTTAGAGAAAGAACCCATAGTAGGAGCAGAAACCTTC";
	RefSeqs[12] = "CCTCAGATCACTCTTTGGCAGCGACCCCTCGTCACAATAAAGATAGGGGGGCAATTAAAGGAAGCTCTATTAGATACAGGAGCAGATGATACAGTATTAGAAGAAATGAATTTGCCAGGAAGATGGAAACCAAAAATGATAGGGGGAATTGGAGGTTTTATCAAAGTAGGACAGTATGATCAGATACTCATAGAAATCTGCGGACATAAAGCTATAGGTACAGTATTAGTAGGACCTACACCTGTCAACATAATTGGAAGAAATCTGTTGACTCAGATTGGCTGCACTTTAAATTTTCCCATTAGTCCTATTGAGACTGTACCAGTAAAATTAAAGCCAGGAATGGATGGCCCAAAAGTTAAACAATGGCCATTGACAGAAGAAAAAATAAAAGCATTAGTAGAAATTTGTACAGAAATGGAAAAGGAAGGAAAAATTTCAAAAATTGGGCCTGAAAATCCATACAATACTCCAGTATTTGCCATAAAGAAAAAAGACAGTACTAAATGGAGAAAATTAGTAGATTTCAGAGAACTTAATAAGAGAACTCAAGATTTCTGGGAAGTTCAATTAGGAATACCACATCCTGCAGGGTTAAAACAGAAAAAATCAGTAACAGTACTGGATGTGGGCGATGCATATTTTTCAGTTCCCTTAGATAAAGACTTCAGGAAGTATACTGCATTTACCATACCTAGTATAAACAATGAGACACCAGGGATTAGATATCAGTACAATGTGCTTCCACAGGGATGGAAAGGATCACCAGCAATATTCCAGTGTAGCATGACAAAAATCTTAGAGCCTTTTAGAAAACAAAATCCAGACATAGTCATCTATCAATACATGGATGATTTGTATGTAGGATCTGACTTAGAAATAGGGCAGCATAGAACAAAAATAGAGGAACTGAGACAACATCTGTTGAGGTGGGGATTTACCACACCAGACAAAAAACATCAGAAAGAACCTCCATTCCTTTGGATGGGTTATGAACTCCATCCTGATAAATGGACAGTACAGCCTATAGTGCTGCCAGAAAAGGACAGCTGGACTGTCAATGACATACAGAAATTAGTGGGAAAATTGAATTGGGCAAGTCAGATTTATGCAGGGATTAAAGTAAGGCAATTATGTAAACTTCTTAGGGGAACCAAAGCACTAACAGAAGTAGTACCACTAACAGAAGAAGCAGAGCTAGAACTGGCAGAAAACAGGGAGATTCTAAAAGAACCGGTACATGGAGTGTATTATGACCCATCAAAAGACTTAATAGCAGAAATACAGAAGCAGGGGCAAGGCCAATGGACATATCAAATTTATCAAGAGCCATTTAAAAATCTGAAAACAGGAAAATATGCAAGAATGAAGGGTGCCCACACTAATGATGTGAAACAATTAACAGAGGCAGTACAAAAAATAGCCACAGAAAGCATAGTAATATGGGGAAAGACTCCTAAATTTAAATTACCCATACAAAAGGAAACATGGGAAGCATGGTGGACAGAGTATTGGCAAGCCACCTGGATTCCTGAGTGGGAGTTTGTCAATACCCCTCCCTTAGTGAAGTTATGGTACCAGTTAGAGAAAGAACCCATAATAGGAGCAGAAACTTTC";
	RefSeqs[13] = "CCTCAGGTCACTCTTTGGCAACGACCCCTCGTCACAATAAAGATAGGGGGGCAACTAAAGGAAGCTCTATTAGATACAGGAGCAGATGATACAGTATTAGAAGAAATGAGTTTGCCAGGAAGATGGAAACCAAAAATGATAGGGGGAATTGGAGGTTTTATCAAAGTAAGACAGTATGATCAGATACTCATAGAAATCTGTGGACATAAAGCTATAGGTACAGTATTAGTAGGACCTACACCTGTCAACATAATTGGAAGAAATCTGTTGACTCAGATTGGTTGCACTTTAAATTTTCCCATTAGCCCTATTGAGACTGTACCAGTAAAATTAAAGCCAGGAATGGATGGCCCAAAAGTTAAACAATGGCCATTGACAGAAGAAAAAATAAAAGCATTAGTAGAAATTTGTACAGAGATGGAAAAGGAAGGGAAAATTTCAAAAATTGGGCCTGAAAATCCATACAATACTCCAGTATTTGCCATAAAGAAAAAAGACAGTACTAAATGGAGAAAATTAGTAGATTTCAGAGAACTTAATAAGAGAACTCAAGACTTCTGGGAAGTTCAATTAGGAATACCACATCCCGCAGGGTTAAAAAAGAAAAAATCAGTAACAGTACTGGATGTGGGTGATGCATATTTTTCAGTTCCCTTAGATGAAGACTTCAGGAAGTATACTGCATTTACCATACCTAGTATAAACAATGAGACACCAGGGATTAGATATCAGTACAATGTGCTTCCACAGGGATGGAAAGGATCACCAGCAATATTCCAAAGTAGCATGACAAAAATCTTAGAGCCTTTTAGAAAACAAAATCCAGACATAGTTATCTATCAATACATGGATGATTTGTATGTAGGATCTGACTTAGAAATAGGGCAGCATAGAACAAAAATAGAGGAGCTGAGACAACATCTGTTGAGGTGGGGACTTACCACACCAGACAAAAAACATCAGAAAGAACCTCCATTCCTTTGGATGGGTTATGAACTCCATCCTGATAAATGGACAGTACAGCCTATAGTGCTGCCAGAAAAAGACAGCTGGACTGTCAATGACATACAGAAGTTAGTGGGGAAATTGAATTGGGCAAGTCAGATTTACCCAGGGATTAAAGTAAGGCAATTATGTAAACTCCTTAGAGGAACCAAAGCACTAACAGAAGTAATACCACTAACAGAAGAAGCAGAGCTAGAACTGGCAGAAAACAGAGAGATTCTAAAAGAACCAGTACATGGAGTGTATTATGACCCATCAAAAGACTTAATAGCAGAAATACAGAAGCAGGGGCAAGGCCAATGGACATATCAAATTTATCAAGAGCCATTTAAAAATCTGAAAACAGGAAAATATGCAAGAATGAGGGGTGCCCACACTAATGATGTAAAACAATTAACAGAGGCAGTGCAAAAAATAACCACAGAAAGCATAGTAATATGGGGAAAGACTCCTAAATTTAAACTGCCCATACAAAAGGAAACATGGGAAACATGGTGGACAGAGTATTGGCAAGCCACCTGGATTCCTGAGTGGGAGTTTGTTAATACCCCTCCCTTAGTGAAATTATGGTACCAGTTAGAGAAAGAACCCATAGTAGGAGCAGAAACCTTCTATGTAGATGGGGCAGCTAACAGGGAGACTAAATTAGGAAAAGCAGGATATGTTACTAATAGAGGAAGACAAAAAGTTGTCACCCTAACTGACACAACAAATCAGAAGACTGAGTTACAAGCAATTTATCTAGCTTTGCAGGATTCGGGATTAGAAGTAAACATAGTAACAGACTCACAATATGCATTAGGAATCATTCAAGCACAACCAGATCAAAGTGAATCAGAGTTAGTCAATCAAATAATAGAGCAGTTAATAAAAAAGGAAAAGGTCTATCTGGCATGGGTACCAGCACACAAAGGAATTGGAGGAAATGAACAAGTAGATAAATTAGTCAGTGCTGGAATCAGGAAAGTACTATTTTTAGATGGAATAGATAAGGCCCAAGATGAACATGAGAAATATCACAGTAATTGGAGAGCAATGGCTAGTGATTTTAACCTGCCACCTGTAGTAGCAAAAGAAATAGTAGCCAGCTGTGATAAATGTCAGCTAAAAGGAGAAGCCATGCATGGACAAGTAGACTGTAGTCCAGGAATATGGCAACTAGATTGTACACATTTAGAAGGAAAAGTTATCCTGGTAGCAGTTCATGTAGCCAGTGGATATATAGAAGCAGAAGTTATTCCAGCAGAAACAGGGCAGGAAACAGCATATTTTCTTTTAAAATTAGCAGGAAGATGGCCAGTAAAAACAATACATACTGACAATGGCAGCAATTTCACCGGTGCTACGGTTAGGGCCGCCTGTTGGTGGGCGGGAATCAAGCAGGAATTTGGAATTCCCTACAATCCCCAAAGTCAAGGAGTAGTAGAATCTATGAATAAAGAATTAAAGAAAATTATAGGACAGGTAAGAGATCAGGCTGAACATCTTAAGACAGCAGTACAAATGGCAGTATTCATCCACAATTTTAAAAGAAAAGGGGGGATTGGGGGGTACAGTGCAGGGGAAAGAATAGTAGACATAATAGCAACAGACATACAAACTAAAGAATTACAAAAACAAATTACAAAAATTCAAAATTTTCGGGTTTATTACAGGGACAGCAGAAATCCACTTTGGAAAGGACCAGCAAAGCTCCTCTGGAAAGGTGAAGGGGCAGTAGTAATACAAGATAATAGTGACATAAAAGTAGTGCCAAGAAGAAAAGCAAAGATCATTAGGGATTATGGAAAACAGATGGCAGGTGATGATTGTGTGGCAAGTAGACAGGATGAGGATTAG";
	
	ChoiceList (refSeq,"Choose a reference sequence",1,SKIP_NONE,predefSeqNames);
	if (refSeq < 0)
	{
		return 0;
	}
}

//---------------------------------------------------------------------------------------------------------------------

function _handleAlignment (dataSetName, writeToFiles)
{
	result = {};

	ExecuteCommands	("DataSetFilter  _alignmentHandlerFilter 	= CreateFilter	("+dataSetName+",1);");
	GetInformation (UnalignedSeqs,_alignmentHandlerFilter );
	
	//preprocess sequences 

	unalSequenceCount = Rows(UnalignedSeqs)*Columns(UnalignedSeqs);
	GetString (sequenceNames, unal, -1);

	longestSequence   	= 0;
	longestSequenceIDX	= 0;

	for (seqCounter = 0; seqCounter < unalSequenceCount; seqCounter = seqCounter+1)
	{
		UnalignedSeqs[seqCounter] = ((UnalignedSeqs[seqCounter]^{{"[^a-zA-Z]",""}})^{{"^N+",""}})^{{"N+$",""}};
		
		if (doLongestSequence)
		{
			if (doLongestSequence == 1 || seqCounter != unalSequenceCount-1)
			{
				if (Abs (UnalignedSeqs[seqCounter]) > longestSequence)
				{
					longestSequence    = Abs (UnalignedSeqs[seqCounter]);
					longestSequenceIDX = seqCounter;
				}
			}
		}
	}

	if (doLongestSequence)
	{
		fprintf			 (stdout, "\nSelected sequence ", sequenceNames[longestSequenceIDX], " as reference.");
		if (longestSequenceIDX > 0)
		{
			p1 				 = UnalignedSeqs[0];
			UnalignedSeqs[0] = UnalignedSeqs[longestSequenceIDX];
			UnalignedSeqs[longestSequenceIDX] = p1;
			p1 				 = sequenceNames[0];
			sequenceNames[0] = sequenceNames[longestSequenceIDX];
			sequenceNames[longestSequenceIDX] = p1;
		}
	}



	/* determine reading frames	*/
	ProteinSequences = {};
	AllTranslations  = {};
	ReadingFrames	 = {};
	StopCodons		 = {};
	StopPositions    = {};
	didRC			 = {};

	fprintf (stdout, "\nDetecting reading frames for each sequence...\n");
	frameCounter  = {3,1};
	stillHasStops = {};

	for (seqCounter = 0; seqCounter < unalSequenceCount; seqCounter += 1)
	{
		aSeq   = UnalignedSeqs[seqCounter];
		seqLen = Abs(aSeq)-2;
		
		minStops = 1e20;
		tString  = "";
		rFrame   = 0;
		
		for (rc = 0; rc <= doRC; rc += 1)
		{
			stopPosn = {3,2};
			allTran  = {3,1};
			if (rc)
			{
				aSeq = nucleotideReverseComplement (aSeq)
			}
			for (offset = 0; offset < 3; offset += 1)
			{
				translString = translateCodonToAA (aSeq, codonToAAMap, offset);
				stopPos = translString||"X";
				if (stopPos[0]>=0)
				{
					stopCount = Rows(stopPos)$2;
					stopPosn[offset][0] = stopPos[0];
					stopPosn[offset][1] = stopPos[stopCount*2-1];
				}
				else
				{
					stopCount = 0;
				}
				if (stopCount<minStops)
				{
					if (rc)
					{
						UnalignedSeqs[seqCounter] = aSeq;
						didRC[seqCounter]		  = 1;
					}
					minStops = stopCount;
					rFrame   = offset;
					tString  = translString;
				}
				allTran[offset] = translString;
			}
		}
		
		ReadingFrames[seqCounter] 		= rFrame;
		ProteinSequences[seqCounter]	= tString;
		frameCounter[rFrame] 			= frameCounter[rFrame]+1;
		StopPositions[seqCounter]		= stopPosn;
		AllTranslations [seqCounter]	= allTran;
		
		if (minStops>0)
		{
			stillHasStops[Abs(stillHasStops)] = seqCounter;
			assert (seqCounter > 0, "Reference sequence must not contain frameshifts\n");
		}
	}

	s1 = ProteinSequences[0];

	fprintf (stdout, "\nFound:\n\t", frameCounter[0], 
					 " sequences in reading frame 1\n\t",frameCounter[1], 
					 " sequences in reading frame 2\n\t",frameCounter[2], 
					 " sequences in reading frame 3\n\n",
					 "There were ", Abs(stillHasStops), " sequences with apparent frameshift/sequencing errors\n");

	skipSeqs = {};

	for (k=0; k<Abs(stillHasStops); k += 1)
	{
		seqCounter = stillHasStops[k];
		seqName = sequenceNames[seqCounter];
		fprintf (stdout,"Sequence ", seqCounter+1, " (", seqName, ") seems to have");
		stopPosn = StopPositions[seqCounter];
		
		fStart = -1;
		fEnd   = -1;
		fMin   = 1e10;
		frame1 = 0;
		frame2 = 0;
		
		checkFramePosition (stopPosn[0][1],stopPosn[1][0],0,1);
		checkFramePosition (stopPosn[1][1],stopPosn[0][0],1,0);
		checkFramePosition (stopPosn[0][1],stopPosn[2][0],0,2);
		checkFramePosition (stopPosn[2][1],stopPosn[0][0],2,0);
		checkFramePosition (stopPosn[2][1],stopPosn[1][0],2,1);
		checkFramePosition (stopPosn[1][1],stopPosn[2][0],1,2);
		
		if (fStart>=0)
		{
			allTran = AllTranslations[seqCounter];
			useq    				   = UnalignedSeqs[seqCounter];
			fprintf (stdout, " a shift from frame ", frame2+1, " to frame ", frame1+1, " between a.a. positions ", fStart, " and ", fEnd, ".");
			fStart2 = Max(fStart-1,0);
			fEnd2   = Min(fEnd+1,Min(Abs(allTran[frame1]),Abs(allTran[frame2]))-1);
			tempString = allTran[frame2];
			fprintf (stdout, "\n\tRegion ", fStart2, "-", fEnd2, " in frame  ", frame2+1, ":\n\t", tempString[fStart2][fEnd2]);
			fprintf (stdout, "\n\t", useq[3*fStart2+frame2][3*fEnd2+frame2-1]);
			tempString = allTran[frame1];
			fprintf (stdout, "\n\tRegion ", fStart2, "-", fEnd2, " in frame  ", frame1+1, ":\n\t", tempString[fStart2][fEnd2]);
			fprintf (stdout, "\n\t", useq[3*fStart2+frame1][3*fEnd2+frame1-1]);
			fprintf (stdout, "\n\t\tAttempting to resolve by alignment to reference. ");
			
			f1s = allTran[frame1];
			f2s = allTran[frame2];
			f1l = Abs(f1s);
			
			bestScore  = -1e10;
			bestSplice = -1;
			
			for (k2=fStart; k2<fEnd; k2=k2+1)
			{
				s2 = f2s[0][k2]+f1s[k2+1][Abs(f1s)];
				inStr = {{s1,s2}};
				AlignSequences(aligned, inStr, alignOptions);
				aligned = aligned[0];
				aligned = aligned[0];
				if (aligned > bestScore)
				{
					bestScore = aligned;
					bestSplice = k2;
					bestString = s2;
				}
			}
			fprintf (stdout, "Best splice site appears to be at a.a. position ", bestSplice, "\n");
			/* update best spliced string */
			
			ProteinSequences[seqCounter] = bestString;
			ReadingFrames[seqCounter]    = 0;
			
			UnalignedSeqs[seqCounter]  = useq[frame2][frame2+3*bestSplice+2] + useq[frame1+3*bestSplice+3][Abs(useq)-1] + "---";
		}
		else
		{
			
			fprintf (stdout, " multiple frameshifts\n");
			skipSeqs[seqCounter] = 1;
		}	
	}

	SeqAlignments 	 = {};
	startingPosition = {unalSequenceCount,2};
	refLength = Abs(ProteinSequences[0]);
	refInsertions	 = {refLength+1,1};

	fprintf (stdout,"\nPerforming pairwise alignment with reference sequences\n");

	alignmentScores = {};

	for (seqCounter = 1; seqCounter < unalSequenceCount; seqCounter += 1)
	{
		if (skipSeqs[seqCounter] == 0)
		{
			s2 			 = ProteinSequences[seqCounter];
			inStr 		 = {{s1,s2}};
			AlignSequences(aligned, inStr, alignOptions);
			aligned = aligned[0];
			SeqAlignments[seqCounter] = aligned;
			alignmentScores +  aligned[0]/Abs(aligned[1]);
			aligned = aligned[1];
			myStartingPosition = aligned$"[^-]";
			myEndingPosition  = Abs (aligned)-1;
			
			while (aligned[myEndingPosition]=="-")
			{
				myEndingPosition = myEndingPosition - 1;
			}
			
			myStartingPosition = myStartingPosition[0];
			startingPosition[seqCounter][0] = myStartingPosition;
			startingPosition[seqCounter][1] = myEndingPosition;
			aligned = aligned[myStartingPosition][myEndingPosition];
			
			refInsert = aligned||"-+";
			if (refInsert[0]>0)
			{
				insCount = Rows (refInsert)/2;
				offset = 0;
				for (insN = 0; insN < insCount; insN = insN+1)
				{
					insPos 		= refInsert[insN*2];
					insLength	= refInsert[insN*2+1]-insPos+1;
					insPos 		= insPos-offset;
					if (refInsertions[insPos]<insLength)
					{
						refInsertions[insPos]=insLength;
					}
					offset = offset + insLength;
				}
			}
		}
	}

	alignmentScoresM = avlToMatrix  ("alignmentScores");
	LoadFunctionLibrary				("DescriptiveStatistics.bf");
	distInfo = 						GatherDescriptiveStats (alignmentScoresM);
	distInfo["Mean"] - 2*distInfo["Std.Dev"];
	
	fprintf (stdout,"\nMerging pairwise alignments into a MSA\n");

	fullRefSeq = "";
	fullRefSeq * refLength;
	fullRefSeq * (s1[0]);


	s1N = UnalignedSeqs[0];

	fullRefSeqN = "";
	fullRefSeqN * (3*refLength);
	fullRefSeqN * (s1N[0][2]);

	frameShift = ReadingFrames[0];

	for (seqCounter=1;seqCounter<refLength;seqCounter=seqCounter+1)
	{
		gapCount = refInsertions[seqCounter];
		for (k=0; k<gapCount;k=k+1)
		{
			fullRefSeq*("-");
			fullRefSeqN*("---");
		}	
		fullRefSeq  * (s1[seqCounter]);
		fullRefSeqN * (s1N[frameShift+seqCounter*3][frameShift+seqCounter*3+2]);
	}

	fullRefSeq * 0;
	fullRefSeqN * 0;

	refLength = Abs(fullRefSeq);

	seqName=sequenceNames[0];
	if (writeToFiles)
	{
	
		SetDialogPrompt ("Save alignment to:");
		fprintf (PROMPT_FOR_FILE,CLEAR_FILE,">",seqName,"\n",fullRefSeq);
		fName = LAST_FILE_PATH;
		fNameC = fName+".nuc";
		fprintf (fNameC,CLEAR_FILE,">",seqName,"\n",fullRefSeqN);
	}
	else
	{
		result [seqName] = fullRefSeqN;
	}
	
	
	alCounter		= 0;

	for (seqCounter = 1; seqCounter < unalSequenceCount; seqCounter += 1)
	{
		if (skipSeqs[seqCounter] == 0)
		{
			if (skipOutliers == 0 && alignmentScoresM[alCounter] < lowerCuttoff)
			{
				seqName=sequenceNames[seqCounter];
				fprintf (stdout, "Sequence ", seqName ," was skipped because of a poor alignment score.\n");
				skipSeqs[seqCounter] = 1;
				alCounter = alCounter + 1;
				continue;
			}
			alCounter = alCounter + 1;
			seqName=sequenceNames[seqCounter];
			aligned = SeqAlignments[seqCounter];
			
			aligned1 = aligned[1];
			aligned2 = aligned[2];
			
			s2 = startingPosition[seqCounter][0];
			e2 = startingPosition[seqCounter][1];
			
			gappedSeq = "";
			gappedSeq * Abs(aligned2);

			
			k=0;
			
			while (k<refLength)
			{
				while (fullRefSeq[k]!=aligned1[s2])
				{
					gappedSeq*("-");
					k=k+1;
				}
				gappedSeq*(aligned2[s2]);
				s2=s2+1;
				k=k+1;
			}

			gappedSeq * 0;

			gappedSeqN = "";
			gappedSeqN * (3*Abs(aligned2));
			
			frameShift = ReadingFrames[seqCounter];

			s1N 	= UnalignedSeqs[seqCounter];
			s2N		= ProteinSequences[seqCounter];
			s2 		= startingPosition[seqCounter][0];
			k 		= 0;
			e2		= Abs(gappedSeq);
			k = 0;
			while  (k<e2)
			{
				while ((s2N[s2]!=gappedSeq[k])&&(k<e2))
				{
					gappedSeqN * ("---");
					k=k+1;
				}
				if (k<e2)
				{
					gappedSeqN * s1N[frameShift+s2*3][frameShift+s2*3+2];
					s2 = s2+1;
					k=k+1;
				}
			}
			gappedSeqN * 0;

			if (writeToFiles)
			{
				if (refSeq2 && seqCounter == unalSequenceCount-1)
				{
					fscanf  (fName, "Raw", soFar);
					fprintf (fName, CLEAR_FILE,">",seqName,"\n",gappedSeq,"\n",soFar);
					fscanf  (fNameC, "Raw", soFar);
					fprintf (fNameC,CLEAR_FILE,">",seqName,"\n",gappedSeqN,"\n",soFar);		
					
				}
				else
				{
					fprintf (fName,"\n>",seqName,"\n",gappedSeq);
					fprintf (fNameC,"\n>",seqName,"\n",gappedSeqN);		
				}
			}
			else
			{
				result [seqName] = gappedSeqN;
			}
		}
	}

	if (Abs(skipSeqs) && writeToFiles)
	{
		fName = fName+".bad";
		for (seqCounter = 1; seqCounter < unalSequenceCount; seqCounter = seqCounter+1)
		{
			if (skipSeqs[seqCounter])
			{
				seqName=sequenceNames[seqCounter];
				fprintf (fName,">",seqName,"\n",UnalignedSeqs[seqCounter],"\n");
			}
		}
	}
	
	return result;
}

//---------------------------------------------------------------------------------------------------------------------


function checkFramePosition (pos1, pos2, fr1, fr2)
{
	fSpan  = pos2-pos1;
	
	if (fSpan>1) // first followed by second
	{
		if (fSpan < fMin)
		{
			fMin = fSpan;
			frame1 = fr1;
			frame2 = fr2;
			fStart = pos1+1;
			fEnd   = pos2;
		}
	}	
	return 0;
}