Java - Nussinov algorithm

 
Vista:

Nussinov algorithm

Publicado por Helena González (2 intervenciones) el 30/11/2021 14:13:29
Hola, alguien me podría ayudar, necesito implementar el algoritmo de nussinov, solo el caso general(que está al final), el caso base ya está hecho. No entiendo muy bien cómo hacerlo. Gracias

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
@Override
	public String getName() {
		return "Nussinov algorithm";
	}
 
	@Override
	protected String _run(String rnaSeq, int minLoopSize) {
		int n = rnaSeq.length();			// number of nucleotides in the sequence
		int[][] M = new int[n][n+1];		// to store costs
		int[][] D = new int[n][n];			// to store decisions
		boolean[][] B = new boolean[n][n];	// to precompute which base pairs match
 
		for (int i=0; i<n; i++)
			for (int j=i+1; j<n; j++)
				B[i][j] = isCompatible(rnaSeq.charAt(i), rnaSeq.charAt(j));
 
		// Computation of the optimal number of base-pairs
		// M(i,j) = maximum number of base pairs when folding the RNA sequence from position i to position j (both inclusive), 0 <= i < n, -1 <= j < n).
		// The range for j must include one unit less than the minimum for i, and since we cannot have negative indices, this means that we have
		// to store M(i,j) at position M[i][j+1].
		// This situation (i = j+1) represents the limit case in which we have an empty sequence. No decision has to be taken in that case
		// and hence the table D does not need a sentinel. Thus, D(i,j) is stored in D[i][j] (and the same for table B).
		//
		// base case: M(i,j) = 0 if j <= i+minloopSize
		for (int i=0; i<n; i++) {
			M[i][i] = 0;				// M(i,i-1) = 0
			for (int j=i, k=0; (k<=minLoopSize) && (j<n); j++, k++) {
				M[i][j+1] = 0;			// M(i,j) = 0;
				D[i][j] = -1;			// -1 => unpaired
			}
		}
 
		// general case: M(i,j) = max(M(i,j-1), max (M(i, k-1) + M(k+1,j-1) + 1 | i <= k < j-minloopSize, s_k and s_j are complementary)) if j > i+minloopSize
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

Nussinov algorithm

Publicado por Maria G (1 intervención) el 01/12/2021 19:24:28
Buenas Helena justo necesito el desarrollo de este algoritmo, me preguntaba si lo resolviste finalmente y podrías hacerme el favor de compartirlo conmigo, me salvarías la vida. Gracias de antemano.
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar