static public Msa parseMsa( final File f ) throws IOException { return parseMsa( new FileInputStream( f ) ); }
final Matcher name_m = NAME_REGEX.matcher( line ); final boolean is_name_line = name_m.lookingAt(); if ( canIgnore( line, saw_first_seq, is_name_line ) ) { continue; if ( is_name_line ) { saw_first_seq = true; addSeq( name, current_seq, temp_msa ); name = new StringBuilder( name_m.group( 1 ).trim() ); current_seq = new StringBuilder(); reader.close(); throw new MsaFormatException( "illegally formatted fasta msa (line: " + line_counter + "):\n\"" + trim( line ) + "\"" ); reader.close(); throw new MsaFormatException( "illegally formatted fasta msa (line: " + line_counter + "):\n\"" + trim( line ) + "\"" ); addSeq( name, current_seq, temp_msa ); reader.close(); final List<MolecularSequence> seqs = new ArrayList<MolecularSequence>();
static public boolean isLikelyFasta( final File f ) throws IOException { return isLikelyFasta( new FileInputStream( f ) ); }
private static boolean testFastaParser() { try { if ( !FastaParser.isLikelyFasta( new FileInputStream( PATH_TO_TEST_DATA + "fasta_0.fasta" ) ) ) { return false; if ( FastaParser.isLikelyFasta( new FileInputStream( PATH_TO_TEST_DATA + "msa_3.txt" ) ) ) { 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;
System.out.println( "STARTING..." ); 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 ) {
List<MolecularSequence> seqs = null; try { if ( FastaParser.isLikelyFasta( new FileInputStream( file ) ) ) { seqs = FastaParser.parse( new FileInputStream( file ) ); for( final MolecularSequence seq : seqs ) { System.out.println( SequenceWriter.toFasta( seq, 60 ) );
static public List<MolecularSequence> parse( final File f ) throws IOException { return parse( new FileInputStream( f ) ); }
static public boolean isLikelyFasta( final InputStream is ) throws IOException { final BufferedReader reader = new BufferedReader( new InputStreamReader( is, "UTF-8" ) ); String line = null; while ( ( line = reader.readLine() ) != null ) { final boolean is_name_line = NAME_REGEX.matcher( line ).lookingAt(); if ( canIgnore( line, true, false ) ) { continue; } else if ( is_name_line ) { reader.close(); return true; } else if ( SEQ_REGEX.matcher( line ).lookingAt() ) { reader.close(); return false; } } reader.close(); return false; }
try { final InputStream is = new FileInputStream( file ); if ( FastaParser.isLikelyFasta( file ) ) { msa = FastaParser.parseMsa( is );
if ( ( file != null ) && !file.isDirectory() && ( result == JFileChooser.APPROVE_OPTION ) ) { try { if ( FastaParser.isLikelyFasta( new FileInputStream( file ) ) ) { seqs = FastaParser.parse( new FileInputStream( file ) );
static public Msa parseMsa( final InputStream is ) throws IOException { return BasicMsa.createInstance( parse( is ) ); }
static public Msa parseMsa( final String s ) throws IOException { return parseMsa( s.getBytes() ); }
if ( FastaParser.isLikelyFasta( in ) ) { msa = FastaParser.parseMsa( is );
private static void execute( final File outdir, final File infile ) { final File outfile = new File( outdir.getAbsolutePath().toString() + "/" + infile.getName() ); if ( outfile.exists() ) { System.out.println( outfile + " already exists" ); } else { try { final List<MolecularSequence> seqs = FastaParser.parse( new FileInputStream( infile ) ); final Map<String, Short> names = new HashMap<String, Short>(); int duplicates = 0; for( final MolecularSequence seq : seqs ) { if ( procSeq( infile.toString(), names, seq ) ) { ++duplicates; } } if ( duplicates > 0 ) { SequenceWriter.writeSeqs( seqs, outfile, SEQ_FORMAT.FASTA, 60 ); } } catch ( final IOException e ) { ForesterUtil.fatalError( PRG_NAME, e.getMessage() ); } } }
static public Msa parseMsa( final byte[] bytes ) throws IOException { return parseMsa( new ByteArrayInputStream( bytes ) ); }
if ( FastaParser.isLikelyFasta( in ) ) { msa = DeleteableMsa.createInstance( FastaParser.parseMsa( is ) );
seqs = FastaParser.parse( new FileInputStream( infile ) );
@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; }
final List<MolecularSequence> too_short = new ArrayList<MolecularSequence>(); final List<MolecularSequence> orig = FastaParser .parse( new FileInputStream( "C:\\Users\\zma\\Desktop\\RRMa_domains_ext_20_2.fasta" ) ); final int initial_number = orig.size(); final List<String> new_seqs = new ArrayList<String>();
@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; }