package fr.orsay.lri.varna.factories; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.Comparator; import java.util.Hashtable; import java.util.Stack; import fr.orsay.lri.varna.exceptions.ExceptionFileFormatOrSyntax; import fr.orsay.lri.varna.exceptions.ExceptionUnmatchedClosingParentheses; import fr.orsay.lri.varna.models.rna.RNA; /** * BH SwingJS -- must explicitly check for array out of bounds */ public class RNAAlignment { private ArrayList _lst = new ArrayList (); private Hashtable _index = new Hashtable (); private Hashtable _accession = new Hashtable (); private String _secStr = ""; public void addSequence(String id, String s) { if (!_index.containsKey(id)) { _index.put(id,_lst.size()); _lst.add(s); } _lst.set(_index.get(id),s); } public void setSecStr(String s) { _secStr = s; } public void setAccession(String id, String AC) { _accession.put(id,AC); } public ArrayList getRNAs() throws ExceptionUnmatchedClosingParentheses { ArrayList result = new ArrayList(); int[] str = RNAFactory.parseSecStr(_secStr); ArrayList ids = new ArrayList(_index.keySet()); Collections.sort(ids,new Comparator(){ public int compare(String o1, String o2) { return o1.compareToIgnoreCase(o2); }}); for (String id: ids ) { int n = _index.get(id); String seq = _lst.get(n); if (seq.length() != str.length) throw new ArrayIndexOutOfBoundsException(); // BH SwingJS -- must explicitly check for array out of bounds String nseq =""; String nstr =""; for(int i=0;i