Improved SRA tests, corrected error message #638

Merged
merged 2 commits into from Jul 29, 2016

Conversation

Projects
None yet
3 participants
Contributor

a-nikitiuk commented Jun 7, 2016 edited

Description

These changes are intended to resolve most of previously reported SRA-related issues:

  • #442 - updated tests to use much smaller files, so that footprint by SRA cache on Mac OS X is about 30 Mb (on other OS issue does not exist, since we use sparse files there and footprint is even smaller)
  • #459, #461 - now each network-related test checks if it can resolve an accession, and skips the test in case of failure
  • #460, #545 - updated error message in SRAFileReader, so that it tells about a possibility of a connection problem

Checklist

  • Code compiles correctly
  • New tests covering changes and new functionality
  • All tests passing
  • Extended the README / documentation, if necessary
  • Is not backward compatible (breaks binary or source compatibility)

Coverage Status

Coverage decreased (-0.006%) to 68.053% when pulling 5d75514 on a-nikitiuk:sra-fixes into e38b849 on samtools:master.

@yfarjoun yfarjoun commented on the diff Jun 10, 2016

src/main/java/htsjdk/samtools/SRAFileReader.java
@@ -61,7 +61,8 @@ public SRAFileReader(final SRAAccession acc) {
this.acc = acc;
if (!acc.isValid()) {
- throw new IllegalArgumentException("Invalid SRA accession was passed to SRA reader: " + acc);
+ throw new IllegalArgumentException("SRAFileReader: cannot resolve SRA accession '" + acc + "'\n" +
@yfarjoun

yfarjoun Jun 10, 2016

Contributor

isn't it clear at some point in the code that a connection has been established but that the accession is bad? why not inform the user?

@yfarjoun yfarjoun commented on the diff Jun 10, 2016

src/test/java/htsjdk/samtools/sra/SRAIndexTest.java
@@ -46,7 +46,7 @@
* Created by andrii.nikitiuk on 10/28/15.
*/
public class SRAIndexTest extends AbstractSRATest {
- private static final SRAAccession DEFAULT_ACCESSION = new SRAAccession("SRR1298981");
+ private static final SRAAccession DEFAULT_ACCESSION = new SRAAccession("SRR2096940");
@yfarjoun

yfarjoun Jun 10, 2016

Contributor

why were these changed? what's wrong with the old ones?

@yfarjoun

yfarjoun Jun 10, 2016

Contributor

sorry, I see the comment now: I supposed these are the smaller files.

@a-nikitiuk

a-nikitiuk Jun 10, 2016

Contributor

yes, that is the reason

Contributor

yfarjoun commented Jun 10, 2016

@a-nikitiuk back to you. only one comment really: can you not distinguish between a bad connection and a bad accesssion string? It seems that some part of the code must know, so perhaps you can give an return code to isValid() that will be more than a boolean and work with that. The problem is that if the accession becomes "bad" because of code change we will never find out because we will skip the test.

Contributor

a-nikitiuk commented Jun 10, 2016

Unfortunately, it is not possible in current version of NGS API. We are working on improvement, but that is not an easy and quick fix.

yfarjoun was assigned by droazen Jun 10, 2016

Contributor

yfarjoun commented Jun 10, 2016

In that case @a-nikitiuk I think it would be better to test connectivity with a single @BeforeGroup using an accession that is bound to exist (perhaps you have some sort of testing object that can be used for that?) and then remove the @BeforeTest so that each of the individual tests will fail if their accession is not valid. while this is fragile wrt losing connectivity in the middle of running the tests, it doesn't require a separate check that all the accessions are valid.

Contributor

yfarjoun commented Jun 28, 2016

@a-nikitiuk This needs to be rebased, and also did you have time to think about my suggestion of using @BeforeGroup rather than @BeforeTest ?

droazen referenced this pull request Jun 28, 2016

Open

Review "Party" #548

Contributor

yfarjoun commented Jul 12, 2016

@a-nikitiuk will you have time to rebase and replace @BeforeMethod with @BeforeTest ?

We would love to have these changes....

Contributor

a-nikitiuk commented Jul 13, 2016

Yeah, will do that. Sorry, did not have much time lately

Contributor

a-nikitiuk commented Jul 13, 2016

Rebased and added @BeforeGroups method

Coverage Status

Coverage increased (+0.006%) to 68.416% when pulling 2fcb11c on a-nikitiuk:sra-fixes into e7c7bf6 on samtools:master.

@yfarjoun yfarjoun commented on the diff Jul 14, 2016

src/test/java/htsjdk/samtools/sra/AbstractSRATest.java
if(!SRAAccession.isSupported()){
throw new SkipException("Skipping SRA Test because SRA native code is unavailable.");
}
}
+ @BeforeMethod
+ public final void skipIfCantResolve(Method method, Object[] params) {
+ String accession = null;
+
+ if (params.length > 0) {
+ Object firstParam = params[0];
+ if (firstParam instanceof String) {
+ accession = (String)firstParam;
+ } else if (firstParam instanceof SRAAccession) {
+ accession = firstParam.toString();
+ }
+ }
+
+ if (accession != null &&
+ accession.matches(SRAAccession.REMOTE_ACCESSION_PATTERN) && !canResolveNetworkAccession) {
@yfarjoun

yfarjoun Jul 14, 2016

Contributor

Since you are no longer asking to connect for every accession, wouldn't it be better to remove the first condition, so that if someone puts in a non-matching accession to a new test, it will fail?

@a-nikitiuk

a-nikitiuk Jul 14, 2016

Contributor

If someone puts a non-matching accession, then this code will do nothing. However, it detects remote accessions from its first argument, and if remote accession is detected and canResolveNetworkAccession is false then it skips the test.

@yfarjoun

yfarjoun Jul 14, 2016

Contributor

Oh, OK. can you then simply change the text in the Exception to:

  1. note the accession that cannot be resolved, and
  2. change "SRA accession" with "remote SRA accession"?
Contributor

yfarjoun commented Jul 26, 2016

@a-nikitiuk are you planing to make these changes, or should I do them?

Contributor

a-nikitiuk commented Jul 26, 2016

You can do them if you would like to. Or I will try to find time for that today-tomorrow

Contributor

yfarjoun commented Jul 26, 2016

OK. I'll leave it to you then! thanks!

On Tue, Jul 26, 2016 at 2:20 PM, a-nikitiuk notifications@github.com
wrote:

You can do them if you would like to. Or I will try to find time for that
today-tomorrow


You are receiving this because you were assigned.
Reply to this email directly, view it on GitHub
#638 (comment), or mute
the thread
https://github.com/notifications/unsubscribe-auth/ACnk0o2DcApbHYeMg6Q2-lK8vfCBKtdtks5qZk_0gaJpZM4Iwd2p
.

@a-nikitiuk a-nikitiuk Network related tests now depend on ability to resolve single SRR0001…
…23 accession
b780a55
Contributor

a-nikitiuk commented Jul 28, 2016

Done

Coverage Status

Coverage decreased (-0.006%) to 68.45% when pulling b780a55 on a-nikitiuk:sra-fixes into 87b1e87 on samtools:master.

Contributor

yfarjoun commented Jul 29, 2016

thanks! 👍

@yfarjoun yfarjoun merged commit 0875b62 into samtools:master Jul 29, 2016

1 of 2 checks passed

coverage/coveralls Coverage decreased (-0.006%) to 68.45%
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details

@jamesemery jamesemery added a commit to jamesemery/htsjdk that referenced this pull request Sep 1, 2016

@a-nikitiuk @jamesemery a-nikitiuk + jamesemery Improved SRA tests, corrected error message (#638)
* Fixed SRA tests issues, corrected error message

* Network related tests now depend on ability to resolve single SRR000123 accession
14d939d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment