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();
- }
+
@Override
public String getAccession() {