Skip to content

SearchIO module - #329

Merged
josemduarte merged 13 commits into
biojava:masterfrom
paolopavan:SearchIO_branch
Nov 12, 2015
Merged

josemduarte merged 13 commits into
biojava:masterfrom
paolopavan:SearchIO_branch

Conversation

@paolopavan

Copy link
Copy Markdown
Contributor

Dear all,
I am submitting changes largely discussed on the mailing list.
Since those changes introduces several variation to the API in terms of alignment package data structures that have moved to core, my advice is to merge this with next major version to warn all developers.

Bye bye,
Paolo

…gnment to biojava-core.

Mantaining main biological data structures in core will help to avoid problems of unwanted dependency. Unfortunately the substitution matrices related classes are tight coupled with SimpleSequencePair class and were moved too from alignment.

Updated pom file to remove dependency of core from alignment module temporary added by first implementation of SearchIO.
@paolopavan

Copy link
Copy Markdown
Contributor Author

I'm sorry guys, I'm now realizing that the structure module that actually I didn't touch it is failing.
I need help by its maintainers: does this module refers some resource as substitution matrices or some test files that previously were in alignment package? The test message is not so clear and seems that an InputStreamReader is failing.

@emckee2006

Copy link
Copy Markdown
Contributor

You might check that your patch didn't accidentally delete those (and other
non intended files)...
On Sep 18, 2015 7:10 AM, "Paolo Pavan" notifications@github.com wrote:

I'm sorry guys, I'm now realizing that the structure module that actually
I didn't touch it is failing.
I need help by its maintainers: does this module refers some resource as
substitution matrices or some test files that previously were in alignment
package? The test message is not so clear and seems that an
InputStreamReader is failing.

—
Reply to this email directly or view it on GitHub
#329 (comment).

@paolopavan

Copy link
Copy Markdown
Contributor Author

Ok, did it! As supposed, it was a hard coded reference to a substitution matrix in a test file. Not so painful.
Now it is patched!

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two comments here:

  • equals should not be implemented by comparing hashCodes. Hash codes do not guarantee equality. Hash equality is a necessary but not sufficient condition for equality (2 different objects can have the same hash)
  • the best way to implement a hashCode is to follow the indications in this SO thread. Actually if you are using eclipse it can even implement such a thing for you automatically, just go to 'Source' -> 'Generate hashCode and equals', you then only need to select which fields of the class should be used (I imagine other IDEs will have similar functions).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have changed the full stuff. I have revisited the way equality is
evaluated and I have modified properties accordingly.

2015-09-22 20:23 GMT+02:00 Jose Manuel Duarte notifications@github.com:

In biojava-core/src/main/java/org/biojava/nbio/core/search/io/Hsp.java
#329 (comment):

  • \* Experimental.
    
  • \* Wants to return an hashcode designed to allow conceptual comparisons of search results.
    
  • \* Fields unrelated to search are deliberately not considered.
    
  • \* @return
    
  • */
    
  • public int hashCode(){
  •    String allInOne = hspQseq+"\n"+hspIdentityString+"\n"+hspHseq;
    
  •    return allInOne.hashCode();
    
  • }
  • @OverRide
  • public boolean equals(Object o){
  •    if (!(o instanceof Hsp)) return false;
    
  •    return o.hashCode() == this.hashCode();
    
  • }

Two comments here:

equals should not be implemented by comparing hashCodes. Hash codes do
not guarantee equality. Hash equality is a necessary but not sufficient
condition for equality (2 different objects can have the same hash)

the best way to implement a hashCode is to follow the indications in this
SO thread
http://stackoverflow.com/questions/113511/best-implementation-for-hashcode-method.
Actually if you are using eclipse it can even implement such a thing for
you automatically, just go to 'Source' -> 'Generate hashCode and equals',
you then only need to select which fields of the class should be used (I
imagine other IDEs will have similar functions).

—
Reply to this email directly or view it on GitHub
https://github.com/biojava/biojava/pull/329/files#r40123811.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Logging in Biojava (since Biojava 4) is happening through the slf4j interface. You should change this to use slf4j. You simply need to import on top:

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

then declare a static variable for the logger:

private static final Logger logger = LoggerFactory.getLogger(Hsp.class);

and then use it like:

logger.error("Unexpected error, could not find compound blah blah ", ex);

See for instance org.biojava.nbio.structure.StructureImpl for an example of the above.

@paolopavan

Copy link
Copy Markdown
Contributor Author

Added discussed final improvements.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants