private final Phylogeny _phy;
private final MainFrameApplication _mf;
private final TreePanel _treepanel;
- private final static boolean DEBUG = true;
+ private final static boolean DEBUG = false;
private enum Db {
UNKNOWN, UNIPROT, EMBL;
max = 20;
}
final StringBuffer sb = new StringBuffer();
- sb.append( "Not all identifiers could be resolved.\n" );
if ( not_found.size() == 1 ) {
- sb.append( "The following identifier was not found:\n" );
+ sb.append( "Data for the following sequence identifier was not found:\n" );
}
else {
- sb.append( "The following identifiers were not found (total: " + not_found.size() + "):\n" );
+ sb.append( "Data for the following sequence identifiers was not found (total: " + not_found.size()
+ + "):\n" );
}
int i = 0;
for( final String string : not_found ) {
try {
JOptionPane.showMessageDialog( _mf,
sb.toString(),
- "UniProt Sequence Tool Completed",
+ "Sequence Tool Completed",
JOptionPane.WARNING_MESSAGE );
}
catch ( final Exception e ) {
// Ignore.
}
}
- else if ( db == Db.EMBL ) {
+ if ( ( db == Db.EMBL ) || ( ( db == Db.UNIPROT ) && ( db_entry == null ) ) ) {
if ( DEBUG ) {
System.out.println( "embl: " + query );
}
catch ( final FileNotFoundException e ) {
// Ignore.
}
+ if ( ( db == Db.UNIPROT ) && ( db_entry != null ) ) {
+ db = Db.EMBL;
+ }
}
- if ( db_entry != null ) {
+ if ( ( db_entry != null ) && !db_entry.isEmpty() ) {
if ( !ForesterUtil.isEmpty( db_entry.getAccession() ) ) {
- seq.setAccession( new Accession( db_entry.getAccession(), "uniprot" ) );
+ String type = null;
+ if ( db == Db.EMBL ) {
+ type = "embl";
+ }
+ else if ( db == Db.UNIPROT ) {
+ type = "uniprot";
+ }
+ seq.setAccession( new Accession( db_entry.getAccession(), type ) );
}
if ( !ForesterUtil.isEmpty( db_entry.getSequenceName() ) ) {
seq.setName( db_entry.getSequenceName() );
import java.util.List;
+import org.forester.util.ForesterUtil;
+
public final class EbiDbEntry implements SequenceDatabaseEntry {
//http://www.ebi.ac.uk/Tools/dbfetch/dbfetch/emb/AAR37336/
final EbiDbEntry e = new EbiDbEntry();
for( final String line : lines ) {
if ( line.startsWith( "PA" ) ) {
- e.setPA( DatabaseTools.extract( line, "PA", ";" ) );
+ e.setPA( DatabaseTools.extract( line, "PA" ) );
}
else if ( line.startsWith( "DE" ) ) {
// if ( ( line.indexOf( "RecName:" ) > 0 ) && ( line.indexOf( "Full=" ) > 0 ) ) {
_symbol = symbol;
}
}
+
+ @Override
+ public boolean isEmpty() {
+ return ( ForesterUtil.isEmpty( getAccession() ) && ForesterUtil.isEmpty( getSequenceName() )
+ && ForesterUtil.isEmpty( getTaxonomyScientificName() )
+ && ForesterUtil.isEmpty( getTaxonomyIdentifier() ) && ForesterUtil.isEmpty( getSequenceSymbol() ) );
+ }
}
public interface SequenceDatabaseEntry {
+ public boolean isEmpty();
+
public String getAccession();
public String getSequenceName();
import java.util.List;
+import org.forester.util.ForesterUtil;
+
public final class UniProtEntry implements SequenceDatabaseEntry {
private String _ac;
_symbol = symbol;
}
}
+
+ @Override
+ public boolean isEmpty() {
+ return ( ForesterUtil.isEmpty( getAccession() ) && ForesterUtil.isEmpty( getSequenceName() )
+ && ForesterUtil.isEmpty( getTaxonomyScientificName() )
+ && ForesterUtil.isEmpty( getTaxonomyIdentifier() ) && ForesterUtil.isEmpty( getSequenceSymbol() ) );
+ }
}
// \Z => end of String
private final static Pattern UNIPROT_AC_PATTERN = Pattern
.compile( "(?:\\A|.*[^a-zA-Z0-9])([A-Z]\\d[A-Z0-9]{3}\\d)(?:[^a-zA-Z0-9]|\\Z)" );
- private final static boolean DEBUG = false;
+ private final static boolean DEBUG = true;
private static String encode( final String str ) throws UnsupportedEncodingException {
return URLEncoder.encode( str.trim(), URL_ENC );
String line;
final List<String> result = new ArrayList<String>();
while ( ( line = in.readLine() ) != null ) {
+ System.out.println( line );
result.add( line );
if ( result.size() > max_lines_to_return ) {
break;
public static SequenceDatabaseEntry obtainEmblEntry( final String query, final int max_lines_to_return )
throws IOException {
- final List<String> lines = queryEmblDb( "query", max_lines_to_return );
+ final List<String> lines = queryEmblDb( query, max_lines_to_return );
return EbiDbEntry.createInstanceFromPlainText( lines );
}
}