+ public RNA trimRNA(RNA rna){
+ RNA rnaTrim = new RNA("trim_"+rna.getName());
+ try {
+ rnaTrim.setRNA(rna.getSeq(),replaceOddGaps(rna.getStructDBN()));
+ } catch (ExceptionUnmatchedClosingParentheses e2) {
+ e2.printStackTrace();
+ } catch (ExceptionFileFormatOrSyntax e3) {
+ e3.printStackTrace();
+ }
+
+ StringBuffer seq=new StringBuffer(rnaTrim.getSeq());
+ StringBuffer struc=new StringBuffer(rnaTrim.getStructDBN());
+ for(int i=0;i<rnaTrim.getSeq().length();i++){
+ //TODO: Jalview utility for gap detection java.utils.isGap()
+ //TODO: Switch to jalview rna datamodel
+ if(seq.substring(i, i+1).compareTo("-")==0 || seq.substring(i, i+1).compareTo(".")==0){
+ if(!rnaTrim.findPair(i).isEmpty()){
+ int m=rnaTrim.findPair(i).get(1);
+ int l=rnaTrim.findPair(i).get(0);
+
+ struc.replace(m, m+1, "*");
+ struc.replace(l, l+1, "*");
+ }else{
+ struc.replace(i, i+1, "*");
+ }
+ }
+ }
+
+ String newSeq=rnaTrim.getSeq().replace("-", "");
+ rnaTrim.getSeq().replace(".", "");
+ String newStruc=struc.toString().replace("*", "");
+
+ try {
+ rnaTrim.setRNA(newSeq,newStruc);
+ } catch (ExceptionUnmatchedClosingParentheses e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (ExceptionFileFormatOrSyntax e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ return rnaTrim;
+ }
+