import java.util.List;
-public final class UniProtEntry {
+import org.forester.util.ForesterUtil;
+
+public final class UniProtEntry implements SequenceDatabaseEntry {
private String _ac;
private String _rec_name;
private UniProtEntry() {
}
- public static UniProtEntry createInstanceFromPlainText( final List<String> lines ) {
+ @Override
+ public Object clone() throws CloneNotSupportedException {
+ throw new CloneNotSupportedException();
+ }
+
+ public static SequenceDatabaseEntry createInstanceFromPlainText( final List<String> lines ) {
final UniProtEntry e = new UniProtEntry();
for( final String line : lines ) {
if ( line.startsWith( "AC" ) ) {
- e.setAc( extract( line, "AC", ";" ) );
+ e.setAc( DatabaseTools.extract( line, "AC", ";" ) );
}
else if ( line.startsWith( "DE" ) ) {
if ( ( line.indexOf( "RecName:" ) > 0 ) && ( line.indexOf( "Full=" ) > 0 ) ) {
- e.setRecName( extract( line, "Full=", ";" ) );
+ e.setRecName( DatabaseTools.extract( line, "Full=", ";" ) );
}
}
else if ( line.startsWith( "GN" ) ) {
if ( ( line.indexOf( "Name=" ) > 0 ) ) {
- e.setSymbol( extract( line, "Name=", ";" ) );
+ e.setSymbol( DatabaseTools.extract( line, "Name=", ";" ) );
}
}
else if ( line.startsWith( "OS" ) ) {
if ( line.indexOf( "(" ) > 0 ) {
- e.setOsScientificName( extract( line, "OS", "(" ) );
+ e.setOsScientificName( DatabaseTools.extract( line, "OS", "(" ) );
}
else {
- e.setOsScientificName( extract( line, "OS", "." ) );
+ e.setOsScientificName( DatabaseTools.extract( line, "OS", "." ) );
}
}
else if ( line.startsWith( "OX" ) ) {
if ( line.indexOf( "NCBI_TaxID=" ) > 0 ) {
- e.setTaxId( extract( line, "NCBI_TaxID=", ";" ) );
+ e.setTaxId( DatabaseTools.extract( line, "NCBI_TaxID=", ";" ) );
}
}
}
return e;
}
- private static String extract( final String target, final String a, final String b ) {
- final int i_a = target.indexOf( a );
- final int i_b = target.indexOf( b );
- if ( ( i_a < 0 ) || ( i_b < i_a ) ) {
- throw new IllegalArgumentException( "attempt to extract from [" + target + "] between [" + a + "] and ["
- + b + "]" );
- }
- return target.substring( i_a + a.length(), i_b ).trim();
- }
-
- public String getAc() {
+ @Override
+ public String getAccession() {
return _ac;
}
}
}
- public String getRecName() {
+ @Override
+ public String getSequenceName() {
return _rec_name;
}
}
}
- public String getOsScientificName() {
+ @Override
+ public String getTaxonomyScientificName() {
return _os_scientific_name;
}
}
}
- public String getTaxId() {
+ @Override
+ public String getTaxonomyIdentifier() {
return _tax_id;
}
}
}
- public String getSymbol() {
+ @Override
+ public String getSequenceSymbol() {
return _symbol;
}
_symbol = symbol;
}
}
+
+ @Override
+ public boolean isEmpty() {
+ return ( ForesterUtil.isEmpty( getAccession() ) && ForesterUtil.isEmpty( getSequenceName() )
+ && ForesterUtil.isEmpty( getTaxonomyScientificName() )
+ && ForesterUtil.isEmpty( getTaxonomyIdentifier() ) && ForesterUtil.isEmpty( getSequenceSymbol() ) );
+ }
+
+ @Override
+ public String getProvider() {
+ return "uniprot";
+ }
}