/* * Created on 17-May-2005 * * TODO To change the template for this generated file go to * Window - Preferences - Java - Code Style - Code Templates */ package org.vamsas.objects.utils; import java.io.BufferedWriter; import java.io.IOException; import java.io.OutputStream; import java.io.OutputStreamWriter; import java.util.regex.Pattern; import org.vamsas.objects.core.AlignmentSequence; import org.vamsas.objects.core.Sequence; import org.vamsas.objects.core.SequenceType; /** * @author jimp * * TODO To change the template for this generated type comment go to * Window - Preferences - Java - Code Style - Code Templates */ public class Seq { public static void write_PirSeq(OutputStream os, SequenceType seq, int wid) throws IOException { BufferedWriter pir_out = new BufferedWriter(new OutputStreamWriter(os)); pir_out.write(">P1;"+seq.getName()+"\n"); int width = (wid<1) ? 80 : wid; for (int j=0,k=seq.getSequence().length(); j"+seq.getName()+"\n"); fasta_out.write(seq.getSequence()+"\n"); fasta_out.flush(); } public static void write_FastaSeq(OutputStream os, SequenceType seq, int wid) throws IOException { BufferedWriter fasta_out = new BufferedWriter(new OutputStreamWriter(os)); fasta_out.write(">"+seq.getName()+"\n"); int width = (wid<1) ? 80 : wid; for (int j=0,k=seq.getSequence().length(); jend on Sequence object if ((start-end)!=Sequence.length()) seq.setEnd(end+Sequence.length()); } return seq; } public static boolean is_valid_aa_seq(SequenceType s) { Sequence q; boolean validref=false; if (s instanceof Sequence) { q=(Sequence) s; if (q.getDictionary()!=null && q.getDictionary().length()>0 || !q.getDictionary().equals(SymbolDictionary.STANDARD_AA)) return false; return valid_aadictionary_string(q.getSequence(), SymbolDictionary.STANDARD_AA); } // follow references if (s instanceof AlignmentSequence) { Object w = (((AlignmentSequence) s).getRefid()); if (w!=null && w!=s && w instanceof SequenceType) return is_valid_aa_seq((SequenceType) w) && valid_aadictionary_string(((AlignmentSequence) s).getSequence(), SymbolDictionary.STANDARD_AA); } return false; } }