X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src2%2Ffr%2Forsay%2Flri%2Fvarna%2Fapplications%2FSecStrConsensus.java;fp=src2%2Ffr%2Forsay%2Flri%2Fvarna%2Fapplications%2FSecStrConsensus.java;h=0000000000000000000000000000000000000000;hb=a1225b9392dc7657d5cef12907385b07527d6122;hp=5fce12bf4d5eb275dcde03730325b65b2a07b028;hpb=b513684c725997c77341f30ce4e584cf9f7cdfed;p=jalview.git diff --git a/src2/fr/orsay/lri/varna/applications/SecStrConsensus.java b/src2/fr/orsay/lri/varna/applications/SecStrConsensus.java deleted file mode 100644 index 5fce12b..0000000 --- a/src2/fr/orsay/lri/varna/applications/SecStrConsensus.java +++ /dev/null @@ -1,189 +0,0 @@ -package fr.orsay.lri.varna.applications; - -import java.util.ArrayList; -import java.util.Hashtable; - -import fr.orsay.lri.varna.models.rna.ModeleBP; - -public class SecStrConsensus { - - - /** - * Internal class to represent a simple base-pair. - * @author Yawn - * - */ - static class SimpleBP{ - int bp5; - int bp3; - - public SimpleBP(int i5, int i3) - { - bp5=i5; - bp3=i3; - } - } - - public static int[] extractConsensus(ArrayList> bps) - { - // We do not currently know the length of the alignment - // => Estimate it as the biggest index of a base-pair plus one. - int maxlength = 0; - for (ArrayList strs : bps) - { - for (SimpleBP bp : strs) - { - maxlength = Math.max(1+Math.max(bp.bp5, bp.bp3), maxlength); - } - } - // Now we have a good estimate for length, allocate and initialize data - // to be fed to the dynamic programming procedure. - ArrayList> seq = new ArrayList>(); - for (int i=0;i()); } - for (ArrayList strs : bps) - { - for (SimpleBP bp : strs) - { - int i = bp.bp5; - int j = bp.bp3; - Hashtable h = seq.get(i); - if (!h.containsKey(j)) - { - h.put(j, 0.0); - } - h.put(j, h.get(i)+1.); - } - } - // At this point, seq contains, at each position i, a hashtable which associates, - // to each possible end j, the number of time a base-pair (i,j) occurs in the alignment - - // We can now run the dynamic programming procedure on this data - double[][] mat = fillMatrix(seq); - ArrayList res = backtrack(mat,seq); - - // Convert it to an array, ie finalres[i] = j >= 0 iff a base-pair (i,j) is present - // in the consensus, or -1 otherwise - int[] finalres = new int[seq.size()]; - for (int i=0;i> seq, int i, int k) - { - return seq.get(i).containsKey(k); - } - - // Returns the score of a potential base-pair, ie the number of structures in which it is found. - private static double basePairScore(ArrayList> seq, int i, int k) - { - return seq.get(i).get(k); - } - - - private static double[][] fillMatrix(ArrayList> seq) - { - int n = seq.size(); - double[][] tab = new double[n][n]; - for(int m=1;m<=n;m++) - { - for(int i=0;ii+1) - { - fact1 = tab[i+1][k-1]; - } - double fact2 = 0; - if (k backtrack(double[][] tab,ArrayList> seq) - { - return backtrack(tab,seq,0,seq.size()-1); - } - - private static ArrayList backtrack(double[][] tab,ArrayList> seq, int i, int j) - { - ArrayList result = new ArrayList(); - if (i indices = new ArrayList(); - indices.add(-1); - for (int k=i+1;k<=j;k++) - { - indices.add(k); - } - for (int k : indices) - { - if (k==-1) - { - if (tab[i][j] == tab[i+1][j]) - { - result = backtrack(tab, seq, i+1,j); - } - } - else - { - if (canBasePair(seq,i,k)) - { - double fact1 = 0; - if (k>i+1) - { - fact1 = tab[i+1][k-1]; - } - double fact2 = 0; - if (k