import charite.christo.strap.*; import static java.lang.System.*; /* java DemoProtein_nucleotides_advanced This demo shows advanced features of proteins translated from nucleotide sequences. */ public class DemoProtein_nucleotides_advanced { public static void main(String argv[]) { final StrapProtein p=new StrapProtein(); out.println("Translate reverse complement"); p.setNucleotides("CCCACCCCACTT",StrapProtein.REVERSE_COMPLEMENT); /* The original strand and the translated (current) strand are distinguished. */ /* The original strand is CCCACCCCACTT. */ /* The current strand is identical or the reverse complement AAGTGGGGTGGG. */ /* This depends on the parameters reverse and complement of the setNucleotides-method. */ out.println("The original NT sequence is "+p.getNucleotidesAsString()); out.println("The NT sequence of current strand is "+p.getNucleotidesCurrentStrandAsString()); out.println("The AA sequence is "+p.getResidueTypeAsString()); out.println(); out.println("You can request nucleotides at any position in the original or the current strand"); out.println("getNucleotide(2)="+(char)p.getNucleotide(2)); out.println("getNucleotideCurrentStrand(2)="+(char)p.getNucleotideCurrentStrand(2)); out.println(); /* By default all nucleotides code amino acids. */ /* But the coding nucleotides can be set explicitly.*/ out.println("The nucleotides 3, 4 and 5 are coding. AAG => Tryptophan"); p.setNucleotidesCurrentStrandTranslated(new boolean[]{false,false,false,true,true,true}); out.println("The NT sequence is "+p.getNucleotidesCurrentStrandAsString()); /* The three coding nucleotides make only one amino acid */ out.println("The AA sequence is "+p.getResidueTypeAsString()); out.println(); /* There are four sequence: */ /* 1. The original nucleotide sequence */ /* 2. The nucleotide sequence of the current strand. */ /* Usually the same or the reverse-complement of the original one. */ /* 3. The coding nucleotide sequence. The length can be divided by 3 */ /* 4. The amino acid sequence. */ /* The following demonstrates conversion of the coordinates. */ out.println("You can convert indices of the current strand to indices of the coding sequence"); out.println("This is like conversion beteen genomic and mRNA positions"); out.println("nucleotideIndices2translatedNucleotideIndices()=" +concat(p.nucleotideIndices2translatedNucleotideIndices(),p.countNucleotides()) +" ( -1 means not translated)"); out.println("translatedNucleotideIndices2nucleotideIndices()=" +concat(p.translatedNucleotideIndices2nucleotideIndices(),p.countCodingNucleotides())); out.println(); out.println("You can convert indices of the current strand to indices of amino acids"); out.println("nucleotideIndex2aminoAcidIndex(6)="+p.nucleotideIndex2aminoAcidIndex(6)); out.println("aminoAcidIndex2nucleotideIndex(2)="+p.aminoAcidIndex2nucleotideIndex(2)); } private static StringBuffer concat(int ii[],int count) { final StringBuffer sb=new StringBuffer(); for(int i=0;i<Math.min(count,ii.length);i++) sb.append(ii[i]).append(" "); return sb; } }