X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src2%2Ffr%2Forsay%2Flri%2Fvarna%2Fmodels%2Ftemplates%2FBenchmark.java;fp=src2%2Ffr%2Forsay%2Flri%2Fvarna%2Fmodels%2Ftemplates%2FBenchmark.java;h=b3db1fdc1e40b0556634dad1a3fb5736ed7c289e;hb=9f55415c9f8005e9dcd8243453883ff853fd5b76;hp=0000000000000000000000000000000000000000;hpb=d8e8c742b864e58406d13e21d124699a26b6492f;p=jalview.git diff --git a/src2/fr/orsay/lri/varna/models/templates/Benchmark.java b/src2/fr/orsay/lri/varna/models/templates/Benchmark.java new file mode 100644 index 0000000..b3db1fd --- /dev/null +++ b/src2/fr/orsay/lri/varna/models/templates/Benchmark.java @@ -0,0 +1,120 @@ +package fr.orsay.lri.varna.models.templates; + +import java.awt.geom.Line2D; +import java.util.Arrays; + +import fr.orsay.lri.varna.models.geom.LinesIntersect; +import fr.orsay.lri.varna.models.rna.RNA; + +/** + * @author Raphael Champeimont + * + */ +public class Benchmark { + private RNA rna; + + // number of backbone crossings + public int backboneCrossings; + // average distance between unpaired consecutive bases + public double averageUnpairedDistance; + // median distance between consecutive bases + public double medianConsecutiveBaseDistance; + // Number of consecutive bases that are too near from each other + public int tooNearConsecutiveBases; + // Number of consecutive bases that are too far from each other + public int tooFarConsecutiveBases; + + + + // Parameters + public double targetConsecutiveBaseDistance = RNA.LOOP_DISTANCE; + // If consecutive bases are nearer that tooNearFactor * target distance, we call them too near. + public double tooNearFactor = 0.5; + // If consecutive bases are further that tooFarFactor * target distance, we call them too far. + public double tooFarFactor = 2; + + + + public Benchmark(RNA rna) { + this.rna = rna; + computeAll(); + } + + private void computeAll() { + // Compute number of backbone crossings + { + int n = rna.getSize(); + Line2D.Double[] lines = new Line2D.Double[n-1]; + for (int i=0; i tooFarFactor*targetConsecutiveBaseDistance) { + tooFarConsecutiveBases++; + } + } + } + } + + @SuppressWarnings("unused") + private int percent(int a, int b) { + return (int) Math.round((double) a / (double) b * 100.0); + } + + public void printAll() { + System.out.println("Benchmark:"); + System.out.println("\tBackbone crossings = " + backboneCrossings); + System.out.println("\tAverage unpaired distance = " + averageUnpairedDistance); + System.out.println("\tMedian of consecutive base distance = " + medianConsecutiveBaseDistance); + System.out.println("\tNumber of too near consecutive bases = " + tooNearConsecutiveBases); // + " ie. " + percent(tooNearConsecutiveBases, rna.getSize()-1) + " %"); + System.out.println("\tNumber of too far consecutive bases = " + tooFarConsecutiveBases); // + " ie. " + percent(tooFarConsecutiveBases, rna.getSize()-1) + " %"); + } +} +