2 package org.forester.application;
4 import java.io.FileInputStream;
5 import java.util.ArrayList;
6 import java.util.HashSet;
9 import java.util.TreeSet;
11 import org.forester.io.parsers.FastaParser;
12 import org.forester.msa.Msa;
13 import org.forester.sequence.Sequence;
14 import org.forester.util.ForesterUtil;
18 public static void main( final String args[] ) {
20 System.out.println( "STARTING..." );
21 final List<Sequence> orig = FastaParser
22 .parse( new FileInputStream( "C:\\Users\\zma\\Desktop\\RRMa_domains_ext_20.fasta" ) );
23 final Msa msa = FastaParser.parseMsa( new FileInputStream( "C:\\Users\\zma\\Desktop\\test3_sorted.fasta" ) );
24 final Set<Sequence> all_found_seqs = new HashSet<Sequence>();
25 for( int i = 0; i < msa.getNumberOfSequences(); ++i ) {
26 final String id = msa.getIdentifier( i );
27 final String id_ = id.substring( 0, id.indexOf( "_" ) );
28 final String range = id.substring( id.indexOf( "[" ) + 1, id.indexOf( "]" ) );
29 //System.out.println( i + ": " + id + "=>" + id_ + " " + range );
30 if ( ForesterUtil.isEmpty( id_ ) ) {
31 System.out.println( "ERROR: id is empty for: " + id );
34 if ( ForesterUtil.isEmpty( range ) ) {
35 System.out.println( "ERROR: range is empty for: " + id );
39 final List<Sequence> found_seqs = new ArrayList<Sequence>();
40 for( final Sequence orig_seq : orig ) {
41 final String orig_seq_id = orig_seq.getIdentifier();
42 if ( orig_seq_id.indexOf( id_ ) >= 0 && orig_seq_id.indexOf( "[" + range + "]" ) >= 0 ) {
44 found_seqs.add( orig_seq );
49 System.out.println( i + ": " + id + "=>" + id_ + " " + range );
50 System.out.println( " found: " + found );
51 for( final Sequence found_seq : found_seqs ) {
52 System.out.println( found_seq.toString() );
57 System.out.println( "ERROR: not found: " + id );
61 System.out.println( "DONE." );
63 catch ( final Exception e ) {