X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src2%2Ffr%2Forsay%2Flri%2Fvarna%2Fmodels%2Ftemplates%2FBatchBenchmarkPrepare.java;fp=src2%2Ffr%2Forsay%2Flri%2Fvarna%2Fmodels%2Ftemplates%2FBatchBenchmarkPrepare.java;h=c3ab8ac55c27bffbea718f63665a54eefed7282d;hb=9f55415c9f8005e9dcd8243453883ff853fd5b76;hp=0000000000000000000000000000000000000000;hpb=d8e8c742b864e58406d13e21d124699a26b6492f;p=jalview.git diff --git a/src2/fr/orsay/lri/varna/models/templates/BatchBenchmarkPrepare.java b/src2/fr/orsay/lri/varna/models/templates/BatchBenchmarkPrepare.java new file mode 100644 index 0000000..c3ab8ac --- /dev/null +++ b/src2/fr/orsay/lri/varna/models/templates/BatchBenchmarkPrepare.java @@ -0,0 +1,98 @@ +/** + * File written by Raphael Champeimont + * UMR 7238 Genomique des Microorganismes + */ +package fr.orsay.lri.varna.models.templates; + +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileWriter; +import java.util.ArrayList; +import java.util.List; + +import fr.orsay.lri.varna.factories.RNAFactory; + +public class BatchBenchmarkPrepare { + + /** + * We assume given directory contains a alignemnt.fasta file, + * of which the first sequence is the consensus structure, + * and the other sequences are aligned nucleotides. + * The principle is to convert it to a set of secondary structure, + * using the following rule: + * - keep the same nucleotides as in original sequence + * - keep base pairs where both bases of the pair are non-gaps in our sequence + */ + public void benchmarkAllDir(File rootdir) throws Exception { + File seqdir = new File(rootdir, "sequences"); + if (!seqdir.exists()) { + seqdir.mkdir(); + } + + File templateFile = new File(rootdir, "template.xml"); + + ArrayList seqnames = new ArrayList(); + ArrayList sequences = new ArrayList(); + BatchBenchmark.readFASTA(new File(rootdir, "alignment.fasta"), seqnames, sequences); + + BufferedWriter outbufASS = new BufferedWriter(new FileWriter(new File(rootdir, "all_secondary_structures.fasta"))); + + String consensusSecStr = sequences.get(0); + int[] consensusSecStrInt = RNAFactory.parseSecStr(consensusSecStr); + + List templates = new ArrayList(); + for (int i=1; i" + seqname + "\n"); + outbuf.write(nt + "\n"); + outbuf.write(ss + "\n"); + outbuf.close(); + + outbufASS.write(">" + seqname + "\n"); + outbufASS.write(ss + "\n"); + + templates.add(templateFile); + } + + outbufASS.close(); + + } + + public static void main(String[] args) throws Exception { + new BatchBenchmarkPrepare().benchmarkAllDir(new File(new File("templates"), "RNaseP_bact_a")); + } + +}