| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
|
| 17 |
|
|
| 18 |
|
|
| 19 |
|
|
| 20 |
|
|
| 21 |
|
package jalview.ext.htsjdk; |
| 22 |
|
|
| 23 |
|
import static org.testng.Assert.assertEquals; |
| 24 |
|
import static org.testng.Assert.assertFalse; |
| 25 |
|
import static org.testng.Assert.assertNotNull; |
| 26 |
|
import static org.testng.Assert.assertTrue; |
| 27 |
|
import static org.testng.Assert.fail; |
| 28 |
|
|
| 29 |
|
import jalview.datamodel.SequenceI; |
| 30 |
|
|
| 31 |
|
import java.io.File; |
| 32 |
|
import java.io.IOException; |
| 33 |
|
import java.nio.file.Files; |
| 34 |
|
import java.nio.file.StandardCopyOption; |
| 35 |
|
|
| 36 |
|
import org.testng.annotations.Test; |
| 37 |
|
|
| 38 |
|
|
| 39 |
|
@author |
| 40 |
|
|
| 41 |
|
|
| |
|
| 86.1% |
Uncovered Elements: 5 (36) |
Complexity: 5 |
Complexity Density: 0.16 |
|
| 42 |
|
public class TestHtsContigDb |
| 43 |
|
{ |
| |
|
| 100% |
Uncovered Elements: 0 (10) |
Complexity: 1 |
Complexity Density: 0.1 |
1PASS
|
|
| 44 |
1 |
@Test(groups = "Functional")... |
| 45 |
|
public final void testGetSequenceProxy() throws Exception |
| 46 |
|
{ |
| 47 |
1 |
String pathname = "test/jalview/ext/htsjdk/pgmB.fasta"; |
| 48 |
1 |
HtsContigDb db = new HtsContigDb("ADB", new File(pathname)); |
| 49 |
|
|
| 50 |
1 |
assertTrue(db.isValid()); |
| 51 |
1 |
assertTrue(db.isIndexed()); |
| 52 |
|
|
| 53 |
1 |
SequenceI sq = db.getSequenceProxy("Deminut"); |
| 54 |
1 |
assertNotNull(sq); |
| 55 |
1 |
assertEquals(sq.getLength(), 606); |
| 56 |
|
|
| 57 |
|
|
| 58 |
|
|
| 59 |
|
|
| 60 |
1 |
sq = db.getSequenceProxy("PPL_06716"); |
| 61 |
1 |
assertNotNull(sq); |
| 62 |
1 |
assertEquals(sq.getLength(), 602); |
| 63 |
|
|
| 64 |
|
|
| 65 |
|
} |
| 66 |
|
|
| 67 |
|
|
| 68 |
|
|
| 69 |
|
|
| 70 |
|
|
| |
|
| 66.7% |
Uncovered Elements: 1 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
1PASS
|
|
| 71 |
1 |
@Test(... |
| 72 |
|
groups = "Functional", |
| 73 |
|
expectedExceptions = java.lang.IllegalArgumentException.class) |
| 74 |
|
public final void testGetSequenceProxy_indexed() |
| 75 |
|
{ |
| 76 |
1 |
String pathname = "test/jalview/ext/htsjdk/pgmB.fasta.fai"; |
| 77 |
1 |
new HtsContigDb("ADB", new File(pathname)); |
| 78 |
0 |
fail("Expected exception opening .fai file"); |
| 79 |
|
} |
| 80 |
|
|
| 81 |
|
|
| 82 |
|
|
| 83 |
|
|
| 84 |
|
|
| 85 |
|
|
| 86 |
|
|
| 87 |
|
|
| 88 |
|
|
| 89 |
|
|
| 90 |
|
@throws |
| 91 |
|
|
| |
|
| 94.1% |
Uncovered Elements: 1 (17) |
Complexity: 2 |
Complexity Density: 0.12 |
1PASS
|
|
| 92 |
1 |
@Test(groups = "Functional")... |
| 93 |
|
public void testCreateFastaSequenceIndex() throws IOException |
| 94 |
|
{ |
| 95 |
1 |
File fasta = new File("test/jalview/ext/htsjdk/pgmB.fasta"); |
| 96 |
|
|
| 97 |
|
|
| 98 |
|
|
| 99 |
|
|
| 100 |
1 |
try |
| 101 |
|
{ |
| 102 |
1 |
HtsContigDb.createFastaSequenceIndex(fasta.toPath(), false); |
| 103 |
0 |
fail("Expected exception"); |
| 104 |
|
} catch (IOException e) |
| 105 |
|
{ |
| 106 |
|
|
| 107 |
|
|
| 108 |
|
} |
| 109 |
|
|
| 110 |
|
|
| 111 |
|
|
| 112 |
|
|
| 113 |
1 |
File copyFasta = File.createTempFile("copyFasta", ".fasta"); |
| 114 |
1 |
copyFasta.deleteOnExit(); |
| 115 |
1 |
assertTrue(copyFasta.exists()); |
| 116 |
1 |
Files.copy(fasta.toPath(), copyFasta.toPath(), |
| 117 |
|
StandardCopyOption.REPLACE_EXISTING); |
| 118 |
|
|
| 119 |
|
|
| 120 |
|
|
| 121 |
|
|
| 122 |
1 |
HtsContigDb db = new HtsContigDb("ADB", copyFasta); |
| 123 |
1 |
assertTrue(db.isValid()); |
| 124 |
1 |
assertFalse(db.isIndexed()); |
| 125 |
1 |
db.close(); |
| 126 |
|
|
| 127 |
|
|
| 128 |
|
|
| 129 |
|
|
| 130 |
1 |
HtsContigDb.createFastaSequenceIndex(copyFasta.toPath(), true); |
| 131 |
1 |
db = new HtsContigDb("ADB", copyFasta); |
| 132 |
1 |
assertTrue(db.isValid()); |
| 133 |
1 |
assertTrue(db.isIndexed()); |
| 134 |
1 |
db.close(); |
| 135 |
|
} |
| 136 |
|
|
| 137 |
|
|
| 138 |
|
|
| 139 |
|
|
| 140 |
|
|
| 141 |
|
@throws |
| 142 |
|
|
| |
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
1PASS
|
|
| 143 |
0 |
@Test(enabled = false)... |
| 144 |
|
public void testCreateIndex() throws IOException |
| 145 |
|
{ |
| 146 |
|
|
| 147 |
0 |
File fasta = new File("test/jalview/io/vcf/contigs.fasta"); |
| 148 |
0 |
HtsContigDb.createFastaSequenceIndex(fasta.toPath(), true); |
| 149 |
|
} |
| 150 |
|
} |