static public Msa parseMsa( final File f ) throws IOException { return parseMsa( new FileInputStream( f ) ); }
static public Msa parseMsa( final String s ) throws IOException { return parseMsa( s.getBytes() ); }
static public Msa parseMsa( final byte[] bytes ) throws IOException { return parseMsa( new ByteArrayInputStream( bytes ) ); }
@Override public Msa infer( final File path_to_input_seqs, final List<String> opts ) throws IOException, InterruptedException { init(); final List<String> my_opts = new ArrayList<String>(); my_opts.add( _path_to_prg ); for( int i = 0; i < opts.size(); i++ ) { my_opts.add( opts.get( i ) ); } my_opts.add( path_to_input_seqs.getAbsolutePath() ); final SystemCommandExecutor command_executor = new SystemCommandExecutor( my_opts ); final int _exit_code = command_executor.executeCommand(); final StringBuilder stderr = command_executor.getStandardErrorFromCommand(); _error = stderr.toString(); if ( _exit_code != 0 ) { throw new IOException( "Clustal Omega program failed, exit code: " + _exit_code + "\nCommand:\n" + my_opts + "\nError:\n" + stderr ); } final StringBuilder stdout = command_executor.getStandardOutputFromCommand(); if ( ( stdout == null ) || ( stdout.length() < 2 ) ) { throw new IOException( "Clustal Omega program did not produce any output\nCommand:\n" + my_opts + "\nError:\n" + stderr ); } final Msa msa = FastaParser.parseMsa( stdout.toString() ); return msa; }
@Override public Msa infer( final File path_to_input_seqs, final List<String> opts ) throws IOException, InterruptedException { init(); final List<String> my_opts = new ArrayList<String>(); my_opts.add( _path_to_prg ); for( int i = 0; i < opts.size(); i++ ) { my_opts.add( opts.get( i ) ); } my_opts.add( path_to_input_seqs.getAbsolutePath() ); final SystemCommandExecutor command_executor = new SystemCommandExecutor( my_opts ); final int _exit_code = command_executor.executeCommand(); final StringBuilder stderr = command_executor.getStandardErrorFromCommand(); _error = stderr.toString(); if ( _exit_code != 0 ) { throw new IOException( "MAFFT program failed, exit code: " + _exit_code + "\nCommand:\n" + my_opts + "\nError:\n" + stderr ); } final StringBuilder stdout = command_executor.getStandardOutputFromCommand(); if ( ( stdout == null ) || ( stdout.length() < 2 ) ) { throw new IOException( "MAFFT program did not produce any output\nCommand:\n" + my_opts + "\nError:\n" + stderr ); } final Msa msa = FastaParser.parseMsa( stdout.toString() ); return msa; }
/** * Convert a BioJava {@link MultipleSequenceAlignment} to a forester * {@link Msa}. The easiest way to convert them is writting the msa as a * FASTA file and then parsing it with the forester {@link FastaParser}. * * @param msa * BioJava MultipleSequenceAlignment * @return forester Msa object * @throws IOException * if the conversion was not possible */ public static <C extends Sequence<D>, D extends Compound> Msa convert( MultipleSequenceAlignment<C, D> msa) throws IOException { // Convert the biojava MSA to a FASTA String OutputStream os = new ByteArrayOutputStream(); FastaWriter<C, D> fastaW = new FastaWriter<C, D>(os, msa.getAlignedSequences(), new FastaHeaderFormatInterface<C, D>() { @Override public String getHeader(C sequence) { return sequence.getAccession().toString(); }; }); fastaW.process(); String fastaMSA = os.toString(); // Parse the FASTA file in forester return FastaParser.parseMsa(fastaMSA); }
return false; final Msa msa_0 = FastaParser.parseMsa( new FileInputStream( PATH_TO_TEST_DATA + "fasta_0.fasta" ) ); if ( !msa_0.getSequenceAsString( 0 ).toString().equalsIgnoreCase( "ACGTGKXFMFDMXEXXXSFMFMF" ) ) { return false;
/** * Convert a BioJava {@link MultipleSequenceAlignment} to a forester * {@link Msa}. The easiest way to convert them is writting the msa as a * FASTA file and then parsing it with the forester {@link FastaParser}. * * @param msa * BioJava MultipleSequenceAlignment * @return forester Msa object * @throws IOException * if the conversion was not possible */ public static <C extends Sequence<D>, D extends Compound> Msa convert( MultipleSequenceAlignment<C, D> msa) throws IOException { // Convert the biojava MSA to a FASTA String OutputStream os = new ByteArrayOutputStream(); FastaWriter<C, D> fastaW = new FastaWriter<C, D>(os, msa.getAlignedSequences(), new FastaHeaderFormatInterface<C, D>() { @Override public String getHeader(C sequence) { return sequence.getAccession().toString(); }; }); fastaW.process(); String fastaMSA = os.toString(); // Parse the FASTA file in forester return FastaParser.parseMsa(fastaMSA); }
/** * Convert a BioJava {@link MultipleSequenceAlignment} to a forester * {@link Msa}. The easiest way to convert them is writting the msa as a * FASTA file and then parsing it with the forester {@link FastaParser}. * * @param msa * BioJava MultipleSequenceAlignment * @return forester Msa object * @throws IOException * if the conversion was not possible */ public static <C extends Sequence<D>, D extends Compound> Msa convert( MultipleSequenceAlignment<C, D> msa) throws IOException { // Convert the biojava MSA to a FASTA String OutputStream os = new ByteArrayOutputStream(); FastaWriter<C, D> fastaW = new FastaWriter<C, D>(os, msa.getAlignedSequences(), new FastaHeaderFormatInterface<C, D>() { @Override public String getHeader(C sequence) { return sequence.getAccession().toString(); }; }); fastaW.process(); String fastaMSA = os.toString(); // Parse the FASTA file in forester return FastaParser.parseMsa(fastaMSA); }
final List<MolecularSequence> orig = FastaParser .parse( new FileInputStream( "C:\\Users\\zma\\Desktop\\RRMa_domains_ext_20.fasta" ) ); final Msa msa = FastaParser.parseMsa( new FileInputStream( "C:\\Users\\zma\\Desktop\\test3_sorted.fasta" ) ); final Set<MolecularSequence> all_found_seqs = new HashSet<MolecularSequence>(); for( int i = 0; i < msa.getNumberOfSequences(); ++i ) {
final InputStream is = new FileInputStream( file ); if ( FastaParser.isLikelyFasta( file ) ) { msa = FastaParser.parseMsa( is );
final InputStream is = new FileInputStream( in ); if ( FastaParser.isLikelyFasta( in ) ) { msa = FastaParser.parseMsa( is );
final FileInputStream is = new FileInputStream( in ); if ( FastaParser.isLikelyFasta( in ) ) { msa = DeleteableMsa.createInstance( FastaParser.parseMsa( is ) );