I have seen 'biojava in anger', but is their a 'biojava cookbook'?
It strikes me that lots of small scripts like this could be useful for lots of people if archived properly. Does the cookbook exist? Cheers, Dan. On Fri, 5 Mar 2004 [EMAIL PROTECTED] wrote: > Hi Gera - > > The code below seems to work for me. Please note that I have not tested it > thoroughly so you might want to eyeball a few results to make sure they > are sensible. > > You could probably improve it by making some of the 'in line' code into > methods etc. > > - Mark > > import java.io.*; > > import org.biojava.bio.*; > import org.biojava.bio.seq.*; > import org.biojava.bio.seq.io.*; > import org.biojava.bio.symbol.*; > > /** > * <p>Program to six-frame translate a nucleotide sequence</p> > */ > > public class Hex { > /** > * Call this to get usage info, program terminates after call. > */ > public static void help() { > System.out.println( > "usage: java utils.Hex <file> <format eg fasta> <dna|rna>"); > System.exit( -1); > } > > public static void main(String[] args) throws Exception{ > if (args.length != 3) { > help(); > } > > BufferedReader br = null; > String format = args[1]; > String alpha = args[2]; > > try { > br = new BufferedReader(new FileReader(args[0])); > > SequenceIterator seqi = > (SequenceIterator)SeqIOTools.fileToBiojava(format, alpha, br); > > //for each sequence > while(seqi.hasNext()){ > Sequence seq = seqi.nextSequence(); > > //for each frame > for (int i = 0; i < 3; i++) { > SymbolList prot; > Sequence trans; > > //take the reading frame > SymbolList syms = seq.subList( > i+1, > seq.length() - (seq.length() - i)%3); > > > //if it is DNA transcribe it to RNA > if(syms.getAlphabet() == DNATools.getDNA()){ > syms = RNATools.transcribe(syms); > } > > //output forward translation to STDOUT > prot = RNATools.translate(syms); > trans = SequenceTools.createSequence(prot, "", > seq.getName()+ > "TranslationFrame: +"+i, > Annotation.EMPTY_ANNOTATION); > SeqIOTools.writeFasta(System.out, trans); > > //output reverse frame translation to STDOUT > syms = RNATools.reverseComplement(syms); > prot = RNATools.translate(syms); > trans = SequenceTools.createSequence(prot, "", > seq.getName() + > "TranslationFrame: -" + i, > Annotation.EMPTY_ANNOTATION); > SeqIOTools.writeFasta(System.out, trans); > } > } > } > finally { > if(br != null){ > br.close(); > } > } > } > } > > > > > > "Jellema, Gera" <[EMAIL PROTECTED]> > Sent by: [EMAIL PROTECTED] > 03/04/2004 09:30 PM > > > To: <[EMAIL PROTECTED]> > cc: > Subject: [Biojava-l] Reading frames and amino acids > > > Hi, > I'm new to biojava so I don't know if this has already been asked. I have > a genome sequence and I want to have it in the 6 reading frames, and then > per reading frame translated into amino acids so I can look for proteins. > I don't know how I have to do it. > Thanks, > Gera > > _______________________________________________ > Biojava-l mailing list - [EMAIL PROTECTED] > http://biojava.org/mailman/listinfo/biojava-l > > [ Attachment ''WINMAIL.DAT'' removed by Mark Schreiber ] > > > _______________________________________________ > Biojava-l mailing list - [EMAIL PROTECTED] > http://biojava.org/mailman/listinfo/biojava-l > _______________________________________________ Biojava-l mailing list - [EMAIL PROTECTED] http://biojava.org/mailman/listinfo/biojava-l