import java.io.*; import java.lang.*; import java.util.*; public class countDMScodons { public int[][] codoncount; public int[][] aacount; public String[] CODONS = new String[] {"AAA", "AAG", "AAC", "AAT", "AGA", "AGG", "AGC", "AGT", "ACA", "ACG", "ACC","ACT", "ATA", "ATG", "ATC","ATT", "GAA", "GAG", "GAC","GAT", "GGA", "GGG", "GGC","GGT", "GCA", "GCG", "GCC","GCT", "GTA", "GTG", "GTC","GTT", "CAA", "CAG", "CAC","CAT", "CGA", "CGG", "CGC","CGT", "CCA", "CCG", "CCC","CCT", "CTA", "CTG", "CTC","CTT", "TAA", "TAG", "TAC","TAT", "TGA", "TGG", "TGC","TGT", "TCA", "TCG", "TCC","TCT", "TTA", "TTG", "TTC","TTT"}; public String[] AACIDS = new String[] {"K", "N", "R", "S", "T", "I", "M", "E","D","G","A","V","Q","H","P","L","*","Y","W","C","F"}; public static void main(String args[]) { new countDMScodons(args[0], Integer.valueOf(args[1]), Integer.valueOf(args[2])); } public countDMScodons(String filename, int start, int stop) { codoncount = new int[(stop-start)/3+1][64]; aacount = new int[(stop-start)/3+1][21]; for(int i =0; i < codoncount.length;i++) for(int j =0; j cluster.getStart() && stop < cluster.getEnd()) { for (int i = 0; (start-cluster.getStart()+i+3) < (stop-cluster.getStart()); i = i+3) { try { if ((start-cluster.getStart()+i+3) < mate1.getaRead().length() && i < (mate2.getStart()-mate1.getStart())) //if mate 1 does not overlap mate 2 { full = full + mate1.getaRead().substring(start-cluster.getStart()+i, start-cluster.getStart()+i+3); } else if((start-cluster.getStart()+i+3) < mate1.getaRead().length() && i +start > mate2.getStart() && (start+i-mate2.getStart()+3) < mate2.getaRead().length()) //if still within mate1 and mate2 has started and hasn't ended (i.e. overlapped) { String s = ""; for (int j = i; j < i+3; j++) { int offset = start+j-mate2.getStart(); if (mate1.getQual().charAt(start-cluster.getStart()+j) > mate2.getQual().charAt(offset)) //(check who has better quality at this base, add to small substring s = s + mate1.getaRead().charAt(start-cluster.getStart()+j); else s = s + mate2.getaRead().charAt(offset); } full = full + s; //add highest quality substring to full } else if(i +start > mate2.getStart() && start+i-mate2.getStart()+3 < mate2.getaRead().length()) //mate 2 non-overlap { int offset = start+i-mate2.getStart(); full = full + mate2.getaRead().substring(offset,offset+3); } } catch (Exception e) { System.out.println("Error parsing cigar"); e.printStackTrace();; System.out.println(mate1.getStart() + " " + mate2.getStart()+" " +i+" " +mate1.getName()+" " +mate1.getaRead()); } //full = full + " "; } } else { ; } if (!full.contains("~") && !full.contains("-")) for (int i = 0; (3*i+3) < full.length(); i++) countCodon(full.substring(3*i, 3*i+3), i); } private void writeCodons(String filename, int start, int stop) { int sum = 0; try { StringTokenizer outfile = new StringTokenizer(filename, "."); String of = outfile.nextToken() + "_"+start+"_"+stop+"_codons.tab"; FileWriter fw = new FileWriter(new File(of)); for (int i=0; i