import java.io.*; import java.util.*; import java.text.*; import org.biojava.bio.*; import org.biojava.bio.symbol.*; import org.biojava.bio.seq.*; import org.biojava.bio.seq.io.*; public class Utils { public Utils() { } public static int[] calcTripletFreq(SymbolList seq, int st, int en) throws Exception { int[] Res = new int[64]; SymbolList LS = seq.subList(st,en); int len = LS.length(); SymbolList Tripl; for(int i=0; i1) ntb = (int)(wSize/6/Bayez); nt = (int)(nt/2)*2+1; ntb = (int)(ntb/2)*2+1; int st = pos-1-(nt-1)*3, en = pos+1+(nt-1)*3; int stb = pos-1-(ntb-1)*3, enb = pos+1+(ntb-1)*3; int fi[] = calcTripletFreq(seq,st,en); int fib[] = new int[64]; if (Bayez>1) fib = calcTripletFreq(seq,stb,enb); for(int i=0; i<64; i++) { if (Bayez>1) Res[i]=(((float)fi[i]+(float)fib[i])/(nt+ntb)); else Res[i]=(float)fi[i]/nt; } return Res; } public static float[] calcTripletFreqF(String s, int pos, int wSize, int Bayez) throws Exception { float[] Res = new float[64]; int nt = (int)(wSize/6); int ntb = 0; if (Bayez>1) ntb = (int)(wSize/6/Bayez); nt = (int)(nt/2)*2+1; ntb = (int)(ntb/2)*2+1; int st = pos-1-(nt-1)*3, en = pos+1+(nt-1)*3; int stb = pos-1-(ntb-1)*3, enb = pos+1+(ntb-1)*3; int fi[] = calcTripletFreq(s,st,en); int fib[] = new int[64]; if (Bayez>1) fib = calcTripletFreq(s,stb,enb); for(int i=0; i<64; i++) { if (Bayez>1) Res[i]=(((float)fi[i]+(float)fib[i])/(nt+ntb)); else Res[i]=(float)fi[i]/nt; } return Res; } /* public static float[] calcTripletFreqF(String s, int st, int en) throws Exception { int[] Res = new int[64]; //SymbolList LS = seq.subList(st,en); String ss = s.substring(st-1,en-1); int len = ss.length(); SymbolList Tripl; for(int i=0; i-1)&&(s.indexOf("intron")==-1)) Res = 1; return Res; } public static int CalcIsCodingGene(Sequence seq, int pos) { int Res = 0; /*for(Iterator i=seq.features(); (i.hasNext())&&(Res==0); ) { Feature Ft = (Feature) i.next(); if ((Ft.getType().equals("CDS"))&&(Ft.getLocation().contains(pos))) Res=1; }*/ String s = GetFeatureName(seq,pos); if(s.indexOf("gene")>-1) Res = 1; return Res; } public static int CalcIsCoding2(Sequence seq, int pos) { int Res = 0; /*for(Iterator i=seq.features(); (i.hasNext())&&(Res==0); ) { Feature Ft = (Feature) i.next(); if ((Ft.getType().equals("CDS"))&&(Ft.getLocation().contains(pos))) Res=1; }*/ String s = GetFeatureName(seq,pos); if(((s.indexOf("CDS")>-1)||(s.indexOf("tRNA")>-1)||(s.indexOf("rRNA")>-1))&&(s.indexOf("intron")==-1)) Res = 1; return Res; } public static int CalcIsGeneComplement(Sequence seq, int pos) { int Res = 0; for(Iterator i=seq.features(); (i.hasNext())&&(Res==0); ) { Feature Ft = (Feature) i.next(); if ((Ft.getType().equals("CDS"))&&(Ft.getLocation().contains(pos))) { Res=1; for (Iterator ai = Ft.getAnnotation().asMap().entrySet().iterator(); ai.hasNext(); ) { Map.Entry me = (Map.Entry) ai.next(); if (me.getKey().toString().equals("internal_data")) if (me.getValue().toString().indexOf("complement")>=0) Res=-1; } } } return Res; } public static int NumberOfBase(StringBuffer seq, char b){ int c=0; for(int i=0;i