-
- public static SortedSet<String> obtainSeqInformation( final Phylogeny phy ) throws IOException {
- final SortedSet<String> not_found = new TreeSet<String>();
- for( final PhylogenyNodeIterator iter = phy.iteratorPostorder(); iter.hasNext(); ) {
- final PhylogenyNode node = iter.next();
- Sequence seq = null;
- Taxonomy tax = null;
- if ( node.getNodeData().isHasSequence() ) {
- seq = node.getNodeData().getSequence();
- }
- else {
- seq = new Sequence();
- }
- if ( node.getNodeData().isHasTaxonomy() ) {
- tax = node.getNodeData().getTaxonomy();
- }
- else {
- tax = new Taxonomy();
- }
- String query = null;
- Db db = Db.UNKNOWN;
- if ( node.getNodeData().isHasSequence() && ( node.getNodeData().getSequence().getAccession() != null )
- && !ForesterUtil.isEmpty( node.getNodeData().getSequence().getAccession().getSource() )
- && !ForesterUtil.isEmpty( node.getNodeData().getSequence().getAccession().getValue() )
- && node.getNodeData().getSequence().getAccession().getValue().toLowerCase().startsWith( "uniprot" ) ) {
- query = node.getNodeData().getSequence().getAccession().getValue();
- db = Db.UNIPROT;
- }
- else if ( node.getNodeData().isHasSequence()
- && ( node.getNodeData().getSequence().getAccession() != null )
- && !ForesterUtil.isEmpty( node.getNodeData().getSequence().getAccession().getSource() )
- && !ForesterUtil.isEmpty( node.getNodeData().getSequence().getAccession().getValue() )
- && ( node.getNodeData().getSequence().getAccession().getValue().toLowerCase().startsWith( "embl" ) || node
- .getNodeData().getSequence().getAccession().getValue().toLowerCase().startsWith( "ebi" ) ) ) {
- query = node.getNodeData().getSequence().getAccession().getValue();
- db = Db.EMBL;
- }
- else if ( !ForesterUtil.isEmpty( node.getName() ) ) {
- if ( ( query = UniProtWsTools.parseUniProtAccessor( node.getName() ) ) != null ) {
- db = Db.UNIPROT;
- }
- else if ( ( query = DatabaseTools.parseGenbankAccessor( node.getName() ) ) != null ) {
- db = Db.EMBL;
- }
- }
- if ( !ForesterUtil.isEmpty( query ) ) {
- SequenceDatabaseEntry db_entry = null;
- if ( db == Db.UNIPROT ) {
- if ( DEBUG ) {
- System.out.println( "uniprot: " + query );
- }
- try {
- db_entry = UniProtWsTools.obtainUniProtEntry( query, 200 );
- }
- catch ( final FileNotFoundException e ) {
- // Ignore.
- }
- }
- else if ( db == Db.EMBL ) {
- if ( DEBUG ) {
- System.out.println( "embl: " + query );
- }
- try {
- db_entry = UniProtWsTools.obtainEmblEntry( query, 200 );
- }
- catch ( final FileNotFoundException e ) {
- // Ignore.
- }
- }
- if ( db_entry != null ) {
- if ( !ForesterUtil.isEmpty( db_entry.getAccession() ) ) {
- seq.setAccession( new Accession( db_entry.getAccession(), "uniprot" ) );
- }
- if ( !ForesterUtil.isEmpty( db_entry.getSequenceName() ) ) {
- seq.setName( db_entry.getSequenceName() );
- }
- if ( !ForesterUtil.isEmpty( db_entry.getSequenceSymbol() ) ) {
- seq.setSymbol( db_entry.getSequenceSymbol() );
- }
- if ( !ForesterUtil.isEmpty( db_entry.getTaxonomyScientificName() ) ) {
- tax.setScientificName( db_entry.getTaxonomyScientificName() );
- }
- if ( !ForesterUtil.isEmpty( db_entry.getTaxonomyIdentifier() ) ) {
- tax.setIdentifier( new Identifier( db_entry.getTaxonomyIdentifier(), "uniprot" ) );
- }
- node.getNodeData().setTaxonomy( tax );
- node.getNodeData().setSequence( seq );
- }
- else {
- not_found.add( node.getName() );
- }
- }
- }
- return not_found;
- }
-
- @Override
- public void run() {
- execute();
- }