-
Notifications
You must be signed in to change notification settings - Fork 15
/
feng_doolittle.js
134 lines (113 loc) · 4.18 KB
/
feng_doolittle.js
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
/*
University of Freiburg WS 2017/2018
Chair for Bioinformatics
Supervisor: Martin Raden
Author: Alexander Mattheis
*/
"use strict";
/**
* Defines tasks after page-loading.
*/
$(document).ready(function () {
if (loaded === ALGORITHMS.FENG_DOOLITTLE) { // to avoid self execution on a script import
fengDoolittle.startFengDoolittle();
loaded = ALGORITHMS.NONE;
}
});
(function () { // namespace
// public methods
namespace("fengDoolittle", startFengDoolittle, FengDoolittle);
// instances
var multiSequenceAlignmentInstance;
var fengDoolittleInstance;
var gotohInstance;
// shared variables
var inputData = {}; // stores the input of the algorithm
var outputData = {}; // stores the output of the algorithm
/**
* Function managing objects.
*/
function startFengDoolittle() {
var multiSequenceInterface = new interfaces.multiSequenceInterface.MultiSequenceInterface();
multiSequenceInterface.startMultiSequenceInterface(FengDoolittle, ALGORITHMS.FENG_DOOLITTLE);
}
/*---- ALGORITHM ----*/
/**
* Computes global affine multi-alignments (non-optimal approach).
* Extended (= affine) version of the original Feng-Doolittle approaches
* between 1986 and 1997.
* @constructor
* @augments MultiSequenceAlignment
* @see https://doi.org/10.1016/S0076-6879(96)66023-6
*
* Feng, Da-Fei, and Russell F. Doolittle.
* "[21] Progressive alignment of amino acid sequences and construction of phylogenetic trees from them."
* Methods in enzymology 266 (1996): 368-382.
*/
function FengDoolittle() {
fengDoolittleInstance = this;
// variables
this.type = ALGORITHMS.FENG_DOOLITTLE;
// instances (do not change order)
multiSequenceAlignmentInstance = new bases.multiSequenceAlignment.MultiSequenceAlignment(this);
gotohInstance = new gotoh.Gotoh();
// public class methods
this.getInput = getInput;
this.setInput = setInput;
this.compute = compute;
this.getOutput = getOutput;
this.setIO = setIO;
this.getSuperclass = getSuperclass;
}
/**
* Returns the input data of the algorithm.
* @return {Object} - Contains all input data.
*/
function getInput() {
return inputData;
}
/**
* Sets the algorithm input for an appropriate algorithm
* which is using the inputViewmodel properties in its computations.
* @param inputViewmodel {Object} - The InputViewmodel of an appropriate algorithm.
*/
function setInput(inputViewmodel) {
multiSequenceAlignmentInstance.setIO(inputData, {});
multiSequenceAlignmentInstance.setInput(inputViewmodel);
}
/**
* Starts the computation.
*/
function compute() {
multiSequenceAlignmentInstance.setIO(inputData, outputData);
multiSequenceAlignmentInstance.computePairwiseData(gotohInstance); // computes scores, number of gaps, alignment lengths, ...
multiSequenceAlignmentInstance.computeDistancesFromSimilarities(); // converting the pairwise similarities into distances
multiSequenceAlignmentInstance.createDistanceMatrix(); // creates a function dist(a,b) between cluster names and distances
multiSequenceAlignmentInstance.createProgressiveAlignment(multiSequenceAlignmentInstance.getPhylogeneticTree());
outputData.score = multiSequenceAlignmentInstance.getAffineSumOfPairsScore(inputData, outputData.progressiveAlignment);
return [inputData, outputData];
}
/**
* Returns all algorithm output.
* @return {Object} - Contains all output of the algorithm.
*/
function getOutput() {
return outputData;
}
/**
* Sets the input and output of an algorithm.
* @param input {Object} - Contains all input data.
* @param output {Object} - Contains all output data.
*/
function setIO(input, output) {
inputData = input;
outputData = output;
}
/**
* Returns the superclass instance.
* @return {Object} - Superclass instance.
*/
function getSuperclass() {
return multiSequenceAlignmentInstance;
}
}());