1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540
|
Author: Olivier Sallou <osallou@debian.org>
Matthias Klose <doko@debian.org>
Subject: disable network tests
Description: remove network related tests
fixing bug 808593
Bug-Debian: https://bugs.debian.org/923539
Last-Updated: 2023-06-13
Forwarded: not-needed
--- a/src/test/java/htsjdk/samtools/seekablestream/SeekableBufferedStreamTest.java
+++ b/src/test/java/htsjdk/samtools/seekablestream/SeekableBufferedStreamTest.java
@@ -42,72 +42,6 @@
private final String BAM_URL_STRING = "http://broadinstitute.github.io/picard/testdata/index_test.bam";
private static File TestFile = new File("src/test/resources/htsjdk/samtools/seekablestream/megabyteZeros.dat");
- /**
- * Test reading across a buffer boundary (buffer size is 512000). The test first reads a range of
- * bytes using an unbuffered stream file stream, then compares this to results from a buffered http stream.
- *
- * @throws IOException
- */
- @Test
- public void testRandomRead() throws IOException {
-
- int startPosition = 500000;
- int length = 50000;
-
- byte[] buffer1 = new byte[length];
- SeekableStream unBufferedStream = new SeekableFileStream(BAM_FILE);
- unBufferedStream.seek(startPosition);
- int bytesRead = unBufferedStream.read(buffer1, 0, length);
- assertEquals(length, bytesRead);
-
- byte[] buffer2 = new byte[length];
- SeekableStream bufferedStream = new SeekableBufferedStream(new SeekableHTTPStream(new URL(BAM_URL_STRING)));
- bufferedStream.seek(startPosition);
- bytesRead = bufferedStream.read(buffer2, 0, length);
- assertEquals(length, bytesRead);
-
- assertEquals(buffer1, buffer2);
- }
-
- @Test
- public void testReadExactlyOneByteAtEndOfFile() throws IOException {
- try (final SeekableStream stream = new SeekableHTTPStream(new URL(BAM_URL_STRING))){
- byte[] buff = new byte[1];
- long length = stream.length();
- stream.seek(length - 1);
- Assert.assertFalse(stream.eof());
- Assert.assertEquals(stream.read(buff), 1);
- Assert.assertTrue(stream.eof());
- Assert.assertEquals(stream.read(buff), -1);
- }
- }
-
-
- /**
- * Test an attempt to read past the end of the file. The test file is 594,149 bytes in length. The test
- * attempts to read a 1000 byte block starting at position 594000. A correct result would return 149 bytes.
- *
- * @throws IOException
- */
- @Test
- public void testEOF() throws IOException {
-
- int remainder = 149;
- long fileLength = BAM_FILE.length();
- long startPosition = fileLength - remainder;
- int length = 1000;
-
-
- byte[] buffer = new byte[length];
- SeekableStream bufferedStream = new SeekableBufferedStream(new SeekableHTTPStream(new URL(BAM_URL_STRING)));
- bufferedStream.seek(startPosition);
- int bytesRead = bufferedStream.read(buffer, 0, length);
- assertEquals(remainder, bytesRead);
-
- // Subsequent reads should return -1
- bytesRead = bufferedStream.read(buffer, 0, length);
- assertEquals(-1, bytesRead);
- }
@Test
public void testSkip() throws IOException {
--- a/src/test/java/htsjdk/samtools/sra/SRAIndexTest.java
+++ b/src/test/java/htsjdk/samtools/sra/SRAIndexTest.java
@@ -50,85 +50,4 @@
private static final int LAST_BIN_LEVEL = GenomicIndexUtil.LEVEL_STARTS.length - 1;
private static final int SRA_BIN_OFFSET = GenomicIndexUtil.LEVEL_STARTS[LAST_BIN_LEVEL];
- @Test
- public void testLevelSize() {
- final SRAIndex index = getIndex(DEFAULT_ACCESSION);
- Assert.assertEquals(index.getLevelSize(0), GenomicIndexUtil.LEVEL_STARTS[1] - GenomicIndexUtil.LEVEL_STARTS[0]);
-
- Assert.assertEquals(index.getLevelSize(LAST_BIN_LEVEL), GenomicIndexUtil.MAX_BINS - GenomicIndexUtil.LEVEL_STARTS[LAST_BIN_LEVEL] - 1);
- }
-
- @Test
- public void testLevelForBin() {
- final SRAIndex index = getIndex(DEFAULT_ACCESSION);
- final Bin bin = new Bin(0, SRA_BIN_OFFSET);
- Assert.assertEquals(index.getLevelForBin(bin), LAST_BIN_LEVEL);
- }
-
- @DataProvider(name = "testBinLocuses")
- private Object[][] createDataForBinLocuses() {
- return new Object[][] {
- {DEFAULT_ACCESSION, 0, 0, 1, SRAIndex.SRA_BIN_SIZE},
- {DEFAULT_ACCESSION, 0, 1, SRAIndex.SRA_BIN_SIZE + 1, SRAIndex.SRA_BIN_SIZE * 2}
- };
- }
-
- @Test(dataProvider = "testBinLocuses")
- public void testBinLocuses(SRAAccession acc, int reference, int binIndex, int firstLocus, int lastLocus) {
- final SRAIndex index = getIndex(acc);
- final Bin bin = new Bin(reference, SRA_BIN_OFFSET + binIndex);
-
- Assert.assertEquals(index.getFirstLocusInBin(bin), firstLocus);
- Assert.assertEquals(index.getLastLocusInBin(bin), lastLocus);
- }
-
- @DataProvider(name = "testBinOverlappings")
- private Object[][] createDataForBinOverlappings() {
- return new Object[][] {
- {DEFAULT_ACCESSION, 0, 1, SRAIndex.SRA_BIN_SIZE, new HashSet<>(Arrays.asList(0))},
- {DEFAULT_ACCESSION, 0, SRAIndex.SRA_BIN_SIZE + 1, SRAIndex.SRA_BIN_SIZE * 2, new HashSet<>(Arrays.asList(1))},
- {DEFAULT_ACCESSION, 0, SRAIndex.SRA_BIN_SIZE + 1, SRAIndex.SRA_BIN_SIZE * 3, new HashSet<>(Arrays.asList(1, 2))},
- {DEFAULT_ACCESSION, 0, SRAIndex.SRA_BIN_SIZE * 2, SRAIndex.SRA_BIN_SIZE * 2 + 1, new HashSet<>(Arrays.asList(1, 2))}
- };
- }
-
-
- @Test(dataProvider = "testBinOverlappings")
- public void testBinOverlappings(SRAAccession acc, int reference, int firstLocus, int lastLocus, Set<Integer> binNumbers) {
- final SRAIndex index = getIndex(acc);
- final Iterator<Bin> binIterator = index.getBinsOverlapping(reference, firstLocus, lastLocus).iterator();
- final Set<Integer> binNumbersFromIndex = new HashSet<>();
- while (binIterator.hasNext()) {
- final Bin bin = binIterator.next();
- binNumbersFromIndex.add(bin.getBinNumber() - SRA_BIN_OFFSET);
- }
-
- Assert.assertEquals(binNumbers, binNumbersFromIndex);
- }
-
- @DataProvider(name = "testSpanOverlappings")
- private Object[][] createDataForSpanOverlappings() {
- return new Object[][] {
- {DEFAULT_ACCESSION, 0, 1, SRAIndex.SRA_BIN_SIZE, new long[] {0, SRAIndex.SRA_CHUNK_SIZE} },
- {DEFAULT_ACCESSION, 0, SRAIndex.SRA_BIN_SIZE * 2, SRAIndex.SRA_BIN_SIZE * 2 + 1, new long[]{0, SRAIndex.SRA_CHUNK_SIZE} },
- {DEFAULT_ACCESSION, 0, SRAIndex.SRA_CHUNK_SIZE, SRAIndex.SRA_CHUNK_SIZE + 1, new long[]{0, SRAIndex.SRA_CHUNK_SIZE, SRAIndex.SRA_CHUNK_SIZE, SRAIndex.SRA_CHUNK_SIZE * 2} },
- };
- }
-
- @Test(dataProvider = "testSpanOverlappings")
- public void testSpanOverlappings(SRAAccession acc, int reference, int firstLocus, int lastLocus, long[] spanCoordinates) {
- final SRAIndex index = getIndex(acc);
- final BAMFileSpan span = index.getSpanOverlapping(reference, firstLocus, lastLocus);
-
- long[] coordinatesFromIndex = span.toCoordinateArray();
-
- Assert.assertTrue(Arrays.equals(coordinatesFromIndex, spanCoordinates),
- "Coordinates mismatch. Expected: " + Arrays.toString(spanCoordinates) +
- " but was : " + Arrays.toString(coordinatesFromIndex));
- }
-
- private SRAIndex getIndex(SRAAccession acc) {
- final SRAFileReader reader = new SRAFileReader(acc);
- return (SRAIndex) reader.getIndex();
- }
}
--- a/src/test/java/htsjdk/samtools/sra/SRATest.java
+++ b/src/test/java/htsjdk/samtools/sra/SRATest.java
@@ -56,378 +56,5 @@
*/
public class SRATest extends AbstractSRATest {
- @DataProvider(name = "testCounts")
- private Object[][] createDataForCounts() {
- return new Object[][] {
- {"SRR2096940", 10591, 498},
- {"SRR000123", 0, 4583}
- };
- }
-
- @Test(dataProvider = "testCounts")
- public void testCounts(String acc, int expectedNumMapped, int expectedNumUnmapped) {
- SamReader reader = SamReaderFactory.make().validationStringency(ValidationStringency.SILENT).open(
- SamInputResource.of(new SRAAccession(acc))
- );
-
- final SAMRecordIterator samRecordIterator = reader.iterator();
-
- assertCorrectCountsOfMappedAndUnmappedRecords(samRecordIterator, expectedNumMapped, expectedNumUnmapped);
- }
-
- @DataProvider(name = "testCountsBySpan")
- private Object[][] createDataForCountsBySpan() {
- return new Object[][] {
- {"SRR2096940", Arrays.asList(new Chunk(0, 59128983), new Chunk(59128983, 59141089)), 10591, 498},
- {"SRR2096940", Arrays.asList(new Chunk(0, 29128983), new Chunk(29128983, 59141089)), 10591, 498},
- {"SRR2096940", Arrays.asList(new Chunk(0, 59134983), new Chunk(59134983, 59141089)), 10591, 498},
- {"SRR2096940", Arrays.asList(new Chunk(0, 59130000)), 10591, 0},
- {"SRR2096940", Arrays.asList(new Chunk(0, 59140889)), 10591, 298}
- };
- }
-
- @Test(dataProvider = "testCountsBySpan")
- public void testCountsBySpan(String acc, List<Chunk> chunks, int expectedNumMapped, int expectedNumUnmapped) {
- SamReader reader = SamReaderFactory.make().validationStringency(ValidationStringency.SILENT).open(
- SamInputResource.of(new SRAAccession(acc))
- );
-
- final SAMRecordIterator samRecordIterator = ((SamReader.Indexing) reader).iterator(new BAMFileSpan(chunks));
-
- assertCorrectCountsOfMappedAndUnmappedRecords(samRecordIterator, expectedNumMapped, expectedNumUnmapped);
- }
-
- @DataProvider(name = "testGroups")
- private Object[][] createDataForGroups() {
- return new Object[][] {
- {"SRR1035115", new TreeSet<>(Arrays.asList("15656144_B09YG", "15656144_B09MR"))},
- {"SRR2096940", new TreeSet<>(Arrays.asList("SRR2096940"))}
- };
- }
-
- @Test(dataProvider = "testGroups")
- public void testGroups(String acc, Set<String> groups) {
- SamReader reader = SamReaderFactory.make().validationStringency(ValidationStringency.SILENT).open(
- SamInputResource.of(new SRAAccession(acc))
- );
-
- final SAMRecordIterator samRecordIterator = reader.iterator();
-
- SAMFileHeader header = reader.getFileHeader();
- Set<String> headerGroups = new TreeSet<>();
- for (SAMReadGroupRecord group : header.getReadGroups()) {
- Assert.assertEquals(group.getReadGroupId(), group.getId());
- headerGroups.add(group.getReadGroupId());
- }
-
- Assert.assertEquals(groups, headerGroups);
-
- Set<String> foundGroups = new TreeSet<>();
-
- for (int i = 0; i < 10000; i++) {
- if (!samRecordIterator.hasNext()) {
- break;
- }
- SAMRecord record = samRecordIterator.next();
- String groupName = (String)record.getAttribute("RG");
-
- foundGroups.add(groupName);
- }
-
- // please note that some groups may be introduced after 10k records, which is not an error
- Assert.assertEquals(groups, foundGroups);
- }
-
- @DataProvider(name = "testReferences")
- private Object[][] createDataForReferences() {
- return new Object[][] {
- // primary alignment only
- {"SRR353866", 9,
- Arrays.asList(
- "AAAB01001871.1", "AAAB01002233.1", "AAAB01004056.1", "AAAB01006027.1",
- "AAAB01008846.1", "AAAB01008859.1", "AAAB01008960.1", "AAAB01008982.1",
- "AAAB01008987.1"
- ),
- Arrays.asList(
- 1115, 1034, 1301, 1007,
- 11308833, 12516315, 23099915, 1015562,
- 16222597
- )},
- };
- }
-
- @Test(dataProvider = "testReferences")
- public void testReferences(String acc, int numberFirstReferenceFound, List<String> references, List<Integer> refLengths) {
- SamReader reader = SamReaderFactory.make().validationStringency(ValidationStringency.SILENT).open(
- SamInputResource.of(new SRAAccession(acc))
- );
-
- final SAMRecordIterator samRecordIterator = reader.iterator();
-
- SAMFileHeader header = reader.getFileHeader();
- Set<String> headerRefNames = new TreeSet<>();
-
- for (SAMSequenceRecord ref : header.getSequenceDictionary().getSequences()) {
- String refName = ref.getSequenceName();
-
- int refIndex = references.indexOf(refName);
- Assert.assertTrue(refIndex != -1, "Unexpected reference: " + refName);
-
- Assert.assertEquals(refLengths.get(refIndex), (Integer) ref.getSequenceLength(), "Reference length is incorrect");
-
- headerRefNames.add(refName);
- }
-
- Assert.assertEquals(new TreeSet<>(references), headerRefNames);
-
- Set<String> foundRefNames = new TreeSet<>();
- for (int i = 0; i < 10000; i++) {
- if (!samRecordIterator.hasNext()) {
- break;
- }
- SAMRecord record = samRecordIterator.next();
-
- if (record.getReferenceIndex().equals(SAMRecord.NO_ALIGNMENT_REFERENCE_INDEX)) {
- continue;
- }
-
- String refName = record.getReferenceName();
- Assert.assertNotNull(refName);
-
- foundRefNames.add(refName);
- }
-
- Assert.assertEquals(new TreeSet<>(references.subList(0, numberFirstReferenceFound)), foundRefNames);
- }
-
- @DataProvider(name = "testRows")
- private Object[][] createDataForRowsTest() {
- return new Object[][] {
- // primary alignment only
- {"SRR2127895", 1, 83, "SRR2127895.R.1",
- "CGTGCGCGTGACCCATCAGATGCTGTTCAATCAGTGGCAAATGCGGAACGGTTTCTGCGGGTTGCCGATATTCTGGAGAGTAATGCCAGGCAGGGGCAGGT",
- "DDBDDDDDBCABC@CCDDDC?99CCA:CDCDDDDDDDECDDDFFFHHHEGIJIIGIJIHIGJIJJJJJJJIIJIIHIGJIJJJIJJIHFFBHHFFFDFBBB",
- 366, "29S72M", "gi|152968582|ref|NC_009648.1|", 147, true, false, false},
-
- // small SRA archive
- {"SRR2096940", 1, 16, "SRR2096940.R.3",
- "GTGTGTCACCAGATAAGGAATCTGCCTAACAGGAGGTGTGGGTTAGACCCAATATCAGGAGACCAGGAAGGAGGAGGCCTAAGGATGGGGCTTTTCTGTCACCAATCCTGTCCCTAGTGGCCCCACTGTGGGGTGGAGGGGACAGATAAAAGTACCCAGAACCAGAG",
- "AAAABFFFFFFFGGGGGGGGIIIIIIIIIIIIIIIIIIIIIIIIIIIIII7IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIGGGGGFGFFDFFFFFC",
- 55627016, "167M", "CM000681.1", 42, false, false, false},
-
- {"SRR2096940", 10591, 4, "SRR2096940.R.10592",
- "CTCTGGTTCTGGGTACTTTTATCTGTCCCCTCCACCCCACAGTGGCGAGCCAGATTCCTTATCTGGTGACACAC",
- "IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII",
- -1, null, null, -1, false, false, false},
-
- // primary and secondary alignments
- {"SRR833251", 81, 393, "SRR833251.R.51",
- "ATGCAAATCCGAATGGGCTATTTGTGGGTACTTGGGCAGGTAAGTAGCTGGCAATCTTGGTCGGTAAACCAATACCCAAGTTCACATAGGCACCATCGGGA",
- "CCCFFFFFHHHHHIJJJIJJJJJIIJJJGIJIJIIJIJJJDGIGIIJIJIHIJJJJJJGIGHIHEDFFFFDDEEEDDDDDCDEEDDDDDDDDDDDDDBBDB",
- 1787186, "38M63S", "gi|169794206|ref|NC_010410.1|", 11, true, true, true},
-
- // local SRA file
- {"src/test/resources/htsjdk/samtools/sra/test_archive.sra", 1, 99, "test_archive.R.2",
- "TGTCGATGCTGAAAGTGTCTGCGGTGAACCACTTCATGCACAGCGCACACTGCAGCTCCACTTCACCCAGCTGACGGCCGTTCTCATCGTCTCCAGAGCCCGTCTGAGCGTCCGCTGCTTCAGAACTGTCCCCGGCTGTATCCTGAAGAC",
- "BBAABBBFAFFFGGGGGGGGGGGGEEFHHHHGHHHHHFHHGHFDGGGGGHHGHHHHHHHHHHHHFHHHGHHHHHHGGGGGGGHGGHHHHHHHHHGHHHHHGGGGHGHHHGGGGGGGGGHHHHEHHHHHHHHHHGCGGGHHHHHHGBFFGF",
- 2811570, "150M", "NC_007121.5", 60, true, false, false}
- };
- }
-
- @Test(dataProvider = "testRows")
- public void testRows(String acc, int recordIndex, int flags, String readName, String bases, String quals, int refStart, String cigar,
- String refName, int mapQ, boolean hasMate, boolean isSecondOfPair, boolean isSecondaryAlignment) {
- SAMRecord record = getRecordByIndex(acc, recordIndex, false);
-
- checkSAMRecord(record, flags, readName, bases, quals, refStart, cigar, refName, mapQ, hasMate, isSecondOfPair, isSecondaryAlignment);
- }
-
- @Test(dataProvider = "testRows")
- public void testRowsAfterIteratorDetach(String acc, int recordIndex, int flags, String readName, String bases, String quals,
- int refStart, String cigar, String refName, int mapQ, boolean hasMate,
- boolean isSecondOfPair, boolean isSecondaryAlignment) {
- SAMRecord record = getRecordByIndex(acc, recordIndex, true);
-
- checkSAMRecord(record, flags, readName, bases, quals, refStart, cigar, refName, mapQ, hasMate, isSecondOfPair, isSecondaryAlignment);
- }
-
- @Test(dataProvider = "testRows")
- public void testRowsOverrideValues(String acc, int recordIndex, int flags, String readName, String bases, String quals,
- int refStart, String cigar, String refName, int mapQ, boolean hasMate,
- boolean isSecondOfPair, boolean isSecondaryAlignment) {
- SAMRecord record = getRecordByIndex(acc, recordIndex, true);
- SAMFileHeader header = record.getHeader();
-
- record.setFlags(0);
- record.setReadUnmappedFlag(refStart == -1);
- record.setReadBases("C".getBytes());
- record.setBaseQualities(SAMUtils.fastqToPhred("A"));
- if (refStart == -1) {
- checkSAMRecord(record, 4, readName, "C", "A", refStart, "1M", refName, mapQ, false, false, false);
- } else {
- int sequenceIndex = header.getSequenceIndex(refName);
- Assert.assertFalse(sequenceIndex == -1);
-
- if (sequenceIndex == 0) {
- if (header.getSequenceDictionary().getSequences().size() > 1) {
- sequenceIndex++;
- }
- } else {
- sequenceIndex--;
- }
-
- refName = header.getSequence(sequenceIndex).getSequenceName();
-
- record.setAlignmentStart(refStart - 100);
- record.setCigarString("1M");
- record.setMappingQuality(mapQ - 1);
- record.setReferenceIndex(sequenceIndex);
-
- checkSAMRecord(record, 0, readName, "C", "A", refStart - 100, "1M", refName, mapQ - 1, false, false, false);
- }
- }
-
- @Test(dataProvider = "testRows")
- public void testRowsBySpan(String acc, int recordIndex, int flags, String readName, String bases, String quals,
- int refStart, String cigar, String refName, int mapQ, boolean hasMate,
- boolean isSecondOfPair, boolean isSecondaryAlignment) {
- SamReader reader = SamReaderFactory.make().validationStringency(ValidationStringency.SILENT).open(
- SamInputResource.of(new SRAAccession(acc))
- );
-
- SAMFileHeader header = reader.getFileHeader();
-
- Chunk chunk;
- if (refStart != -1) {
- long refOffset = 0;
- int refIndex = header.getSequenceDictionary().getSequence(refName).getSequenceIndex();
- for (SAMSequenceRecord sequenceRecord : header.getSequenceDictionary().getSequences()) {
- if (sequenceRecord.getSequenceIndex() < refIndex) {
- refOffset += sequenceRecord.getSequenceLength();
- }
- }
-
- chunk = new Chunk(refOffset + refStart - 1, refOffset + refStart);
- } else {
- long totalRefLength = header.getSequenceDictionary().getReferenceLength();
- long totalRecordRange = ((BAMFileSpan)reader.indexing().getFilePointerSpanningReads()).toCoordinateArray()[1];
- chunk = new Chunk(totalRefLength, totalRecordRange);
- }
-
- final SAMRecordIterator samRecordIterator = ((SamReader.Indexing) reader).iterator(new BAMFileSpan(chunk));
-
- SAMRecord record = null;
- while (samRecordIterator.hasNext()) {
- SAMRecord currentRecord = samRecordIterator.next();
- if (currentRecord.getReadName().equals(readName)) {
- record = currentRecord;
- break;
- }
- }
-
- checkSAMRecord(record, flags, readName, bases, quals, refStart, cigar, refName, mapQ, hasMate, isSecondOfPair, isSecondaryAlignment);
- }
-
- @Test(dataProvider = "testRows")
- public void testRowsByIndex(String acc, int recordIndex, int flags, String readName, String bases, String quals,
- int refStart, String cigar, String refName, int mapQ, boolean hasMate,
- boolean isSecondOfPair, boolean isSecondaryAlignment) {
- SamReader reader = SamReaderFactory.make().validationStringency(ValidationStringency.SILENT).open(
- SamInputResource.of(new SRAAccession(acc))
- );
-
- Assert.assertTrue(reader.hasIndex());
- Assert.assertTrue(reader.indexing().hasBrowseableIndex());
-
- SAMFileHeader header = reader.getFileHeader();
- BrowseableBAMIndex index = reader.indexing().getBrowseableIndex();
-
- BAMFileSpan span;
- if (refStart != -1) {
- int refIndex = header.getSequenceDictionary().getSequence(refName).getSequenceIndex();
- span = index.getSpanOverlapping(refIndex, refStart, refStart + 1);
- } else {
- long chunkStart = index.getStartOfLastLinearBin();
- long totalRecordRange = ((BAMFileSpan) reader.indexing().getFilePointerSpanningReads()).toCoordinateArray()[1];
- span = new BAMFileSpan(new Chunk(chunkStart, totalRecordRange));
- }
-
- final SAMRecordIterator samRecordIterator = ((SamReader.Indexing) reader).iterator(span);
-
- SAMRecord record = null;
- while (samRecordIterator.hasNext()) {
- SAMRecord currentRecord = samRecordIterator.next();
- if (refStart != -1 && currentRecord.getAlignmentStart() + currentRecord.getReadLength() < refStart) {
- continue;
- }
-
- if (currentRecord.getReadName().equals(readName)
- && currentRecord.isSecondaryAlignment() == isSecondaryAlignment
- && (!hasMate || currentRecord.getSecondOfPairFlag() == isSecondOfPair)) {
- record = currentRecord;
- break;
- }
- }
-
- checkSAMRecord(record, flags, readName, bases, quals, refStart, cigar, refName, mapQ, hasMate, isSecondOfPair, isSecondaryAlignment);
- }
-
- private SAMRecord getRecordByIndex(String acc, int recordIndex, boolean detach) {
- SamReader reader = SamReaderFactory.make().validationStringency(ValidationStringency.SILENT).open(
- SamInputResource.of(new SRAAccession(acc))
- );
-
- final SAMRecordIterator samRecordIterator = reader.iterator();
-
- while (recordIndex != 0) {
- Assert.assertTrue(samRecordIterator.hasNext(), "Record set is too small");
-
- samRecordIterator.next();
- recordIndex--;
- }
- Assert.assertTrue(samRecordIterator.hasNext(), "Record set is too small");
-
- SAMRecord record = samRecordIterator.next();
-
- if (detach) {
- samRecordIterator.next();
- }
-
- return record;
- }
-
- private void checkSAMRecord(SAMRecord record, int flags, String readName, String bases, String quals,
- int refStart, String cigar, String refName, int mapQ, boolean hasMate,
- boolean isSecondOfPair, boolean isSecondaryAlignment) {
-
- Assert.assertNotNull(record, "Record with read id: " + readName + " was not found by span created from index");
-
- List<SAMValidationError> validationErrors = record.isValid();
- Assert.assertNull(validationErrors, "SRA Lazy record is invalid. List of errors: " +
- (validationErrors != null ? validationErrors.toString() : ""));
-
- Assert.assertEquals(record.getReadName(), readName);
- Assert.assertEquals(new String(record.getReadBases()), bases);
- Assert.assertEquals(record.getBaseQualityString(), quals);
- Assert.assertEquals(record.getReadPairedFlag(), hasMate);
- Assert.assertEquals(record.getFlags(), flags);
- Assert.assertEquals(record.isSecondaryAlignment(), isSecondaryAlignment);
- if (hasMate) {
- Assert.assertEquals(record.getSecondOfPairFlag(), isSecondOfPair);
- }
- if (refStart == -1) {
- Assert.assertEquals(record.getReadUnmappedFlag(), true);
- Assert.assertEquals(record.getAlignmentStart(), 0);
- Assert.assertEquals(record.getCigarString(), "*");
- Assert.assertEquals(record.getReferenceName(), "*");
- Assert.assertEquals(record.getMappingQuality(), 0);
- } else {
- Assert.assertEquals(record.getReadUnmappedFlag(), false);
- Assert.assertEquals(record.getAlignmentStart(), refStart);
- Assert.assertEquals(record.getCigarString(), cigar);
- Assert.assertEquals(record.getReferenceName(), refName);
- Assert.assertEquals(record.getMappingQuality(), mapQ);
- }
- }
}
--- a/src/test/java/htsjdk/tribble/util/ftp/FTPClientTest.java
+++ b/src/test/java/htsjdk/tribble/util/ftp/FTPClientTest.java
@@ -25,225 +25,4 @@
static byte[] expectedBytes = "abcdefghijklmnopqrstuvwxyz\n".getBytes();
FTPClient client;
- @BeforeMethod
- public void setUp() throws IOException {
- client = new FTPClient();
- FTPReply reply = client.connect(host);
- Assert.assertTrue(reply.isSuccess(), "connect");
- }
-
- @AfterMethod
- public void tearDown() {
- System.out.println("Disconnecting");
- client.disconnect();
- }
-
- @Test
- public void testLogin() throws Exception {
-
- }
-
- @Test
- public void testPasv() throws Exception {
- try {
- FTPReply reply = client.login("anonymous", "igv@broadinstitute.org");
- Assert.assertTrue(reply.isSuccess(), "login");
-
- reply = client.pasv();
- Assert.assertTrue(reply.isSuccess(), "pasv");
- } finally {
- client.closeDataStream();
- }
- }
-
- @Test
- public void testSize() throws Exception {
-
- FTPReply reply = client.login("anonymous", "igv@broadinstitute.org");
- Assert.assertTrue(reply.isSuccess());
-
- reply = client.binary();
- Assert.assertTrue(reply.isSuccess(), "binary");
-
- reply = client.size(file);
- String val = reply.getReplyString();
- int size = Integer.parseInt(val);
- Assert.assertEquals(fileSize, size, "size");
- }
-
- @Test
- public void testDownload() throws Exception {
- try {
- FTPReply reply = client.login("anonymous", "igv@broadinstitute.org");
- Assert.assertTrue(reply.isSuccess(), "login");
-
- reply = client.binary();
- Assert.assertTrue(reply.isSuccess(), "binary");
-
- reply = client.pasv();
- Assert.assertTrue(reply.isSuccess(), "pasv");
-
- reply = client.retr(file);
- Assert.assertEquals(reply.getCode(), 150, "retr");
-
- InputStream is = client.getDataStream();
- int idx = 0;
- int b;
- while ((b = is.read()) >= 0) {
- Assert.assertEquals(expectedBytes[idx], (byte) b,"reading from stream");
- idx++;
- }
-
- } finally {
- client.closeDataStream();
- FTPReply reply = client.retr(file);
- System.out.println(reply.getCode());
- Assert.assertTrue(reply.isSuccess(), "close");
- }
- }
-
- @Test
- public void testRest() throws Exception {
- try {
- FTPReply reply = client.login("anonymous", "igv@broadinstitute.org");
- Assert.assertTrue(reply.isSuccess(), "login");
-
- reply = client.binary();
- Assert.assertTrue(reply.isSuccess(), "binary");
-
- reply = client.pasv();
- Assert.assertTrue(reply.isSuccess(), "pasv");
-
- final int restPosition = 5;
- client.setRestPosition(restPosition);
-
- reply = client.retr(file);
- Assert.assertEquals(reply.getCode(), 150, "retr");
-
- InputStream is = client.getDataStream();
- int idx = restPosition;
- int b;
- while ((b = is.read()) >= 0) {
- Assert.assertEquals(expectedBytes[idx], (byte) b, "reading from stream");
- idx++;
- }
-
- } finally {
- client.closeDataStream();
- FTPReply reply = client.retr(file);
- System.out.println(reply.getCode());
- Assert.assertTrue(reply.isSuccess(), "close");
- }
- }
-
- /**
- * Test accessing a non-existent file
- */
- @Test
- public void testNonExistentFile() throws Exception {
-
- String host = "ftp.broadinstitute.org";
- String file = "/pub/igv/TEST/fileDoesntExist.txt";
- FTPClient client = new FTPClient();
-
- FTPReply reply = client.connect(host);
- Assert.assertTrue(reply.isSuccess(), "connect");
-
- reply = client.login("anonymous", "igv@broadinstitute.org");
- Assert.assertTrue(reply.isSuccess(), "login");
-
- reply = client.binary();
- Assert.assertTrue(reply.isSuccess(), "binary");
-
- reply = client.executeCommand("size " + file);
- Assert.assertEquals(550, reply.getCode(), "size");
-
- client.disconnect();
- }
-
- /**
- * Test accessing a non-existent server
- */
- @Test
- public void testNonExistentServer() throws Exception {
-
- String host = "ftp.noSuchServer.org";
- String file = "/pub/igv/TEST/fileDoesntExist.txt";
- FTPClient client = new FTPClient();
-
- FTPReply reply = null;
- try {
- reply = client.connect(host);
- } catch (UnknownHostException e) {
- // This is expected
- }
-
- client.disconnect();
- }
-
- @Test
- public void testMultiplePasv() throws Exception {
-
- try {
- FTPReply reply = client.login("anonymous", "igv@broadinstitute.org");
- Assert.assertTrue(reply.isSuccess(), "login");
-
- reply = client.pasv();
- Assert.assertTrue(reply.isSuccess(), "pasv 1");
- client.closeDataStream();
-
- reply = client.pasv();
- Assert.assertTrue(reply.isSuccess(), "pasv 2");
- client.closeDataStream();
- }
- finally {
-
- }
- }
-
- @Test
- public void testMultipleRest() throws Exception {
- FTPReply reply = client.login("anonymous", "igv@broadinstitute.org");
- Assert.assertTrue(reply.isSuccess(), "login");
-
- reply = client.binary();
- Assert.assertTrue(reply.isSuccess(), "binary");
-
- restRetr(5, 10);
- restRetr(2, 10);
- restRetr(15, 10);
- }
-
- private void restRetr(int restPosition, int length) throws IOException {
-
- try {
-
- if (client.getDataStream() == null) {
- FTPReply reply = client.pasv();
- Assert.assertTrue(reply.isSuccess(), "pasv");
- }
-
- client.setRestPosition(restPosition);
-
- FTPReply reply = client.retr(file);
- //assertTrue(reply.getCode() == 150);
-
- InputStream is = client.getDataStream();
-
- byte[] buffer = new byte[length];
- is.read(buffer);
-
- for (int i = 0; i < length; i++) {
- System.out.print((char) buffer[i]);
- Assert.assertEquals(expectedBytes[i + restPosition], buffer[i], "reading from stream");
- }
- System.out.println();
- }
-
- finally {
- client.closeDataStream();
- FTPReply reply = client.getReply(); // <== MUST READ THE REPLY
- System.out.println(reply.getReplyString());
- }
- }
}
--- a/src/test/java/htsjdk/tribble/readers/TabixReaderTest.java
+++ b/src/test/java/htsjdk/tribble/readers/TabixReaderTest.java
@@ -164,29 +164,6 @@
}
/**
- * Test reading a tabix file over http
- *
- * @throws java.io.IOException
- */
- @Test
- public void testRemoteQuery() throws IOException {
- String tabixFile = TestUtil.BASE_URL_FOR_HTTP_TESTS +"igvdata/tabix/trioDup.vcf.gz";
-
- try(TabixReader tabixReader = new TabixReader(tabixFile)) {
- TabixIteratorLineReader lineReader = new TabixIteratorLineReader(
- tabixReader.query(tabixReader.chr2tid("4"), 320, 330));
-
- int nRecords = 0;
- String nextLine;
- while ((nextLine = lineReader.readLine()) != null) {
- Assert.assertTrue(nextLine.startsWith("4"));
- nRecords++;
- }
- Assert.assertTrue(nRecords > 0);
- }
- }
-
- /**
* Test TabixReader.readLine
*
* @throws java.io.IOException
--- a/src/test/java/htsjdk/samtools/cram/ref/EnaRefServiceTest.java
+++ b/src/test/java/htsjdk/samtools/cram/ref/EnaRefServiceTest.java
@@ -13,9 +13,4 @@
return new Object[][]{{"57151e6196306db5d9f33133572a5482"},
{"0000088cbcebe818eb431d58c908c698"}};
}
-
- @Test(dataProvider = "testEnaRefServiceData", groups = "ena")
- public void testEnaRefServiceData(final String md5) throws GaveUpException {
- Assert.assertNotNull(new EnaRefService().getSequence(md5));
- }
}
--- a/src/test/java/htsjdk/samtools/BAMRemoteFileTest.java
+++ b/src/test/java/htsjdk/samtools/BAMRemoteFileTest.java
@@ -44,276 +44,7 @@
public class BAMRemoteFileTest extends HtsjdkTest {
private final File BAM_INDEX_FILE = new File("src/test/resources/htsjdk/samtools/BAMFileIndexTest/index_test.bam.bai");
private final File BAM_FILE = new File("src/test/resources/htsjdk/samtools/BAMFileIndexTest/index_test.bam");
- private final String BAM_URL_STRING = TestUtil.BASE_URL_FOR_HTTP_TESTS + "index_test.bam";
- private final URL bamURL;
private final boolean mVerbose = false;
- public BAMRemoteFileTest() throws Exception {
- bamURL = new URL(BAM_URL_STRING);
- }
-
-
- @Test
- public void testRemoteLocal() throws Exception {
- runLocalRemoteTest(bamURL, BAM_FILE, "chrM", 10400, 10600, false);
- }
-
- @Test
- public void testSpecificQueries() throws Exception {
- assertEquals(runQueryTest(bamURL, "chrM", 10400, 10600, true), 1);
- assertEquals(runQueryTest(bamURL, "chrM", 10400, 10600, false), 2);
- }
-
- @Test
- public void testRandomQueries() throws Exception {
- runRandomTest(bamURL, 20, new Random(TestUtil.RANDOM_SEED));
- }
-
- @Test
- public void testWholeChromosomes() {
- checkChromosome("chrM", 23);
- checkChromosome("chr1", 885);
- checkChromosome("chr2", 837);
- /***
- checkChromosome("chr3", 683);
- checkChromosome("chr4", 633);
- checkChromosome("chr5", 611);
- checkChromosome("chr6", 585);
- checkChromosome("chr7", 521);
- checkChromosome("chr8", 507);
- checkChromosome("chr9", 388);
- checkChromosome("chr10", 477);
- checkChromosome("chr11", 467);
- checkChromosome("chr12", 459);
- checkChromosome("chr13", 327);
- checkChromosome("chr14", 310);
- checkChromosome("chr15", 280);
- checkChromosome("chr16", 278);
- checkChromosome("chr17", 269);
- checkChromosome("chr18", 265);
- checkChromosome("chr19", 178);
- checkChromosome("chr20", 228);
- checkChromosome("chr21", 123);
- checkChromosome("chr22", 121);
- checkChromosome("chrX", 237);
- checkChromosome("chrY", 29);
- ***/
- }
-
-
- private void checkChromosome(final String name, final int expectedCount) {
- int count = runQueryTest(bamURL, name, 0, 0, true);
- assertEquals(count, expectedCount);
- count = runQueryTest(bamURL, name, 0, 0, false);
- assertEquals(count, expectedCount);
- }
-
- private void runRandomTest(final URL bamFile, final int count, final Random generator) throws IOException {
- final int maxCoordinate = 10000000;
- final List<String> referenceNames = getReferenceNames(bamFile);
- for (int i = 0; i < count; i++) {
- final String refName = referenceNames.get(generator.nextInt(referenceNames.size()));
- final int coord1 = generator.nextInt(maxCoordinate + 1);
- final int coord2 = generator.nextInt(maxCoordinate + 1);
- final int startPos = Math.min(coord1, coord2);
- final int endPos = Math.max(coord1, coord2);
- System.out.println("Testing query " + refName + ":" + startPos + "-" + endPos + " ...");
- try {
- runQueryTest(bamFile, refName, startPos, endPos, true);
- runQueryTest(bamFile, refName, startPos, endPos, false);
- } catch (Throwable exc) {
- String message = "Query test failed: " + refName + ":" + startPos + "-" + endPos;
- message += ": " + exc.getMessage();
- throw new RuntimeException(message, exc);
- }
- }
- }
-
- private List<String> getReferenceNames(final URL bamFile) throws IOException {
-
- final SamReader reader = SamReaderFactory.makeDefault().open(SamInputResource.of(bamFile.openStream()));
-
- final List<String> result = new ArrayList<String>();
- final List<SAMSequenceRecord> seqRecords = reader.getFileHeader().getSequenceDictionary().getSequences();
- for (final SAMSequenceRecord seqRecord : seqRecords) {
- if (seqRecord.getSequenceName() != null) {
- result.add(seqRecord.getSequenceName());
- }
- }
- reader.close();
- return result;
- }
-
- private void runLocalRemoteTest(final URL bamURL, final File bamFile, final String sequence, final int startPos, final int endPos, final boolean contained) {
- verbose("Testing query " + sequence + ":" + startPos + "-" + endPos + " ...");
- final SamReader reader1 = SamReaderFactory.makeDefault()
- .disable(SamReaderFactory.Option.EAGERLY_DECODE)
- .open(SamInputResource.of(bamFile).index(BAM_INDEX_FILE));
- final SamReader reader2 = SamReaderFactory.makeDefault()
- .disable(SamReaderFactory.Option.EAGERLY_DECODE)
- .open(SamInputResource.of(bamURL).index(BAM_INDEX_FILE));
- final Iterator<SAMRecord> iter1 = reader1.query(sequence, startPos, endPos, contained);
- final Iterator<SAMRecord> iter2 = reader2.query(sequence, startPos, endPos, contained);
-
- final List<SAMRecord> records1 = new ArrayList<SAMRecord>();
- final List<SAMRecord> records2 = new ArrayList<SAMRecord>();
-
- while (iter1.hasNext()) {
- records1.add(iter1.next());
- }
- while (iter2.hasNext()) {
- records2.add(iter2.next());
- }
-
- assertTrue(records1.size() > 0);
- assertEquals(records1.size(), records2.size());
- for (int i = 0; i < records1.size(); i++) {
- //System.out.println(records1.get(i).format());
- assertEquals(records1.get(i).getSAMString(), records2.get(i).getSAMString());
- }
- }
-
- private int runQueryTest(final URL bamURL, final String sequence, final int startPos, final int endPos, final boolean contained) {
- verbose("Testing query " + sequence + ":" + startPos + "-" + endPos + " ...");
- final SamReader reader1 = SamReaderFactory.makeDefault()
- .disable(SamReaderFactory.Option.EAGERLY_DECODE)
- .open(SamInputResource.of(bamURL).index(BAM_INDEX_FILE));
- final SamReader reader2 = SamReaderFactory.makeDefault()
- .disable(SamReaderFactory.Option.EAGERLY_DECODE)
- .open(SamInputResource.of(bamURL).index(BAM_INDEX_FILE));
- final Iterator<SAMRecord> iter1 = reader1.query(sequence, startPos, endPos, contained);
- final Iterator<SAMRecord> iter2 = reader2.iterator();
- // Compare ordered iterators.
- // Confirm that iter1 is a subset of iter2 that properly filters.
- SAMRecord record1 = null;
- SAMRecord record2 = null;
- int count1 = 0;
- int count2 = 0;
- int beforeCount = 0;
- int afterCount = 0;
- while (true) {
- if (record1 == null && iter1.hasNext()) {
- record1 = iter1.next();
- count1++;
- }
- if (record2 == null && iter2.hasNext()) {
- record2 = iter2.next();
- count2++;
- }
- if (record1 == null && record2 == null) {
- break;
- }
- if (record1 == null) {
- checkPassesFilter(false, record2, sequence, startPos, endPos, contained);
- record2 = null;
- afterCount++;
- continue;
- }
- assertNotNull(record2);
- final int ordering = compareCoordinates(record1, record2);
- if (ordering > 0) {
- checkPassesFilter(false, record2, sequence, startPos, endPos, contained);
- record2 = null;
- beforeCount++;
- continue;
- }
- assertTrue(ordering == 0);
- checkPassesFilter(true, record1, sequence, startPos, endPos, contained);
- checkPassesFilter(true, record2, sequence, startPos, endPos, contained);
- assertEquals(record1.getReadName(), record2.getReadName());
- assertEquals(record1.getReadString(), record2.getReadString());
- record1 = null;
- record2 = null;
- }
- CloserUtil.close(reader1);
- CloserUtil.close(reader2);
- verbose("Checked " + count1 + " records against " + count2 + " records.");
- verbose("Found " + (count2 - beforeCount - afterCount) + " records matching.");
- verbose("Found " + beforeCount + " records before.");
- verbose("Found " + afterCount + " records after.");
- return count1;
- }
-
- private void checkPassesFilter(final boolean expected, final SAMRecord record, final String sequence, final int startPos, final int endPos, final boolean contained) {
- final boolean passes = passesFilter(record, sequence, startPos, endPos, contained);
- if (passes != expected) {
- System.out.println("Error: Record erroneously " +
- (passes ? "passed" : "failed") +
- " filter.");
- System.out.println(" Record: " + record.getSAMString());
- System.out.println(" Filter: " + sequence + ":" +
- startPos + "-" + endPos +
- " (" + (contained ? "contained" : "overlapping") + ")");
- assertEquals(passes, expected);
- }
- }
-
- private boolean passesFilter(final SAMRecord record, final String sequence, final int startPos, final int endPos, final boolean contained) {
- if (record == null) {
- return false;
- }
- if (!safeEquals(record.getReferenceName(), sequence)) {
- return false;
- }
- final int alignmentStart = record.getAlignmentStart();
- int alignmentEnd = record.getAlignmentEnd();
- if (alignmentStart <= 0) {
- assertTrue(record.getReadUnmappedFlag());
- return false;
- }
- if (alignmentEnd <= 0) {
- // For indexing-only records, treat as single base alignment.
- assertTrue(record.getReadUnmappedFlag());
- alignmentEnd = alignmentStart;
- }
- if (contained) {
- if (startPos != 0 && alignmentStart < startPos) {
- return false;
- }
- if (endPos != 0 && alignmentEnd > endPos) {
- return false;
- }
- } else {
- if (startPos != 0 && alignmentEnd < startPos) {
- return false;
- }
- if (endPos != 0 && alignmentStart > endPos) {
- return false;
- }
- }
- return true;
- }
-
- private int compareCoordinates(final SAMRecord record1, final SAMRecord record2) {
- final int seqIndex1 = record1.getReferenceIndex();
- final int seqIndex2 = record2.getReferenceIndex();
- if (seqIndex1 == -1) {
- return ((seqIndex2 == -1) ? 0 : -1);
- } else if (seqIndex2 == -1) {
- return 1;
- }
- int result = seqIndex1 - seqIndex2;
- if (result != 0) {
- return result;
- }
- result = record1.getAlignmentStart() - record2.getAlignmentStart();
- return result;
- }
-
- private boolean safeEquals(final Object o1, final Object o2) {
- if (o1 == o2) {
- return true;
- } else if (o1 == null || o2 == null) {
- return false;
- } else {
- return o1.equals(o2);
- }
- }
-
- private void verbose(final String text) {
- if (mVerbose) {
- System.out.println("# " + text);
- }
- }
}
--- a/src/test/java/htsjdk/tribble/util/ftp/FTPUtilsTest.java
+++ b/src/test/java/htsjdk/tribble/util/ftp/FTPUtilsTest.java
@@ -15,18 +15,4 @@
*/
public class FTPUtilsTest extends HtsjdkTest {
- @Test(groups ="ftp")
- public void testResourceAvailable() throws Exception {
-
- URL goodUrl = new URL("ftp://ftp.broadinstitute.org/pub/igv/TEST/test.txt");
- assertTrue(FTPUtils.resourceAvailable(goodUrl));
-
- URL nonExistentURL = new URL("ftp://ftp.broadinstitute.org/pub/igv/TEST/doesntExist");
- assertFalse(FTPUtils.resourceAvailable(nonExistentURL));
-
- URL nonExistentServer = new URL("ftp://noSuchServer/pub/igv/TEST/doesntExist");
- assertFalse(FTPUtils.resourceAvailable(nonExistentServer));
-
-
- }
}
--- a/src/test/java/htsjdk/samtools/seekablestream/SeekableFTPStreamTest.java
+++ b/src/test/java/htsjdk/samtools/seekablestream/SeekableFTPStreamTest.java
@@ -40,67 +40,6 @@
public class SeekableFTPStreamTest extends HtsjdkTest {
- static String urlString = "ftp://ftp.broadinstitute.org/pub/igv/TEST/test.txt";
- static long fileSize = 27;
- static byte[] expectedBytes = "abcdefghijklmnopqrstuvwxyz\n".getBytes();
- SeekableFTPStream stream;
-
- @BeforeMethod()
- public void setUp() throws IOException {
- stream = new SeekableFTPStream(new URL(urlString));
-
- }
-
- @AfterMethod()
- public void tearDown() throws IOException {
- stream.close();
- }
-
- @Test
- public void testLength() throws Exception {
- long length = stream.length();
- Assert.assertEquals(fileSize, length);
- }
-
-
- /**
- * Test a buffered read. The buffer is much large than the file size, assert that the desired # of bytes are read
- *
- * @throws Exception
- */
- @Test
- public void testBufferedRead() throws Exception {
-
- byte[] buffer = new byte[64000];
- int nRead = stream.read(buffer);
- Assert.assertEquals(fileSize, nRead);
-
- }
-
- /**
- * Test requesting a range that extends beyond the end of the file
- */
-
- @Test
- public void testRange() throws Exception {
- stream.seek(20);
- byte[] buffer = new byte[64000];
- int nRead = stream.read(buffer);
- Assert.assertEquals(fileSize - 20, nRead);
-
- }
-
- /**
- * Test requesting a range that begins beyond the end of the file
- */
-
- @Test
- public void testBadRange() throws Exception {
- stream.seek(30);
- byte[] buffer = new byte[64000];
- int nRead = stream.read(buffer);
- Assert.assertEquals(-1, nRead);
- }
}
--- a/src/test/java/htsjdk/tribble/util/ParsingUtilsTest.java
+++ b/src/test/java/htsjdk/tribble/util/ParsingUtilsTest.java
@@ -156,68 +156,7 @@
}
}
- @Test(groups = "ftp")
- public void testFTPDoesExist() throws IOException{
- testExists(AVAILABLE_FTP_URL, true);
- }
-
- @Test(groups = "ftp")
- public void testFTPNotExist() throws IOException{
- testExists(UNAVAILABLE_FTP_URL, false);
- }
-
- @Test
- public void testHTTPDoesExist() throws IOException{
- testExists(AVAILABLE_HTTP_URL, true);
- }
-
- @Test
- public void testHTTPNotExist() throws IOException{
- testExists(UNAVAILABLE_HTTP_URL, false);
- }
-
-
private static void testExists(String path, boolean expectExists) throws IOException{
Assert.assertEquals(ParsingUtils.resourceExists(path), expectExists);
}
-
- @Test
- public void testFileOpenInputStream() throws IOException{
- File tempFile = File.createTempFile(getClass().getSimpleName(), ".tmp");
- tempFile.deleteOnExit();
- try(Writer writer = new BufferedWriter(new OutputStreamWriter(IOUtil.openFileForWriting(tempFile)))) {
- writer.write("hello");
- }
- testStream(tempFile.getAbsolutePath());
- testStream(tempFile.toURI().toString());
- }
-
- @Test
- public void testInMemoryNioFileOpenInputStream() throws IOException{
- try(FileSystem fs = Jimfs.newFileSystem(Configuration.unix())) {
- Path file = fs.getPath("/file");
- Files.write(file, "hello".getBytes(StandardCharsets.UTF_8));
- testStream(file.toUri().toString());
- }
- }
-
- @Test(groups = "ftp")
- public void testFTPOpenInputStream() throws IOException{
- testStream(AVAILABLE_FTP_URL);
- }
-
- @Test
- public void testHTTPOpenInputStream() throws IOException{
- testStream(AVAILABLE_HTTP_URL);
- }
-
- private static void testStream(String path) throws IOException{
- try(InputStream is = ParsingUtils.openInputStream(path)) {
- Assert.assertNotNull(is, "InputStream is null for " + path);
- int b = is.read();
- Assert.assertNotSame(b, -1);
- }
- }
-
-
}
--- a/src/test/java/htsjdk/tribble/AbstractFeatureReaderTest.java
+++ b/src/test/java/htsjdk/tribble/AbstractFeatureReaderTest.java
@@ -53,53 +53,6 @@
//wrapper which skips the first byte of a file and leaves the rest unchanged
private static final Function<SeekableByteChannel, SeekableByteChannel> WRAPPER = SkippingByteChannel::new;
- /**
- * Asserts readability and correctness of VCF over HTTP. The VCF is indexed and requires and index.
- */
- @Test
- public void testVcfOverHTTP() throws IOException {
- final VCFCodec codec = new VCFCodec();
- final AbstractFeatureReader<VariantContext, LineIterator> featureReaderHttp =
- AbstractFeatureReader.getFeatureReader(HTTP_INDEXED_VCF_PATH, codec, true); // Require an index to
- final AbstractFeatureReader<VariantContext, LineIterator> featureReaderLocal =
- AbstractFeatureReader.getFeatureReader(LOCAL_MIRROR_HTTP_INDEXED_VCF_PATH, codec, false);
- final CloseableTribbleIterator<VariantContext> localIterator = featureReaderLocal.iterator();
- for (final Feature feat : featureReaderHttp.iterator()) {
- assertEquals(feat.toString(), localIterator.next().toString());
- }
- assertFalse(localIterator.hasNext());
- }
-
- @Test(groups = "ftp")
- public void testLoadBEDFTP() throws Exception {
- final String path = "ftp://ftp.broadinstitute.org/distribution/igv/TEST/cpgIslands%20with%20spaces.hg18.bed";
- final BEDCodec codec = new BEDCodec();
- final AbstractFeatureReader<BEDFeature, LineIterator> bfs = AbstractFeatureReader.getFeatureReader(path, codec, false);
- for (final Feature feat : bfs.iterator()) {
- assertNotNull(feat);
- }
- }
-
- @Test(dataProvider = "blockCompressedExtensionExtensionStrings", dataProviderClass = IOUtilTest.class)
- public void testBlockCompressionExtensionString(final String testString, final boolean expected) {
- Assert.assertEquals(AbstractFeatureReader.hasBlockCompressedExtension(testString), expected);
- }
-
- @Test(dataProvider = "blockCompressedExtensionExtensionStrings", dataProviderClass = IOUtilTest.class)
- public void testBlockCompressionExtensionFile(final String testString, final boolean expected) {
- Assert.assertEquals(AbstractFeatureReader.hasBlockCompressedExtension(new File(testString)), expected);
- }
-
- @Test(dataProvider = "blockCompressedExtensionExtensionURIStrings", dataProviderClass = IOUtilTest.class)
- public void testBlockCompressionExtension(final String testURIString, final boolean expected) {
- URI testURI = URI.create(testURIString);
- Assert.assertEquals(AbstractFeatureReader.hasBlockCompressedExtension(testURI), expected);
- }
-
- @Test(dataProvider = "blockCompressedExtensionExtensionURIStrings", dataProviderClass = IOUtilTest.class)
- public void testBlockCompressionExtensionStringVersion(final String testURIString, final boolean expected) {
- Assert.assertEquals(AbstractFeatureReader.hasBlockCompressedExtension(testURIString), expected);
- }
@Test(groups = "optimistic_vcf_4_4")
public void testVCF4_4Optimistic() {
final AbstractFeatureReader<VariantContext, ?> fr = AbstractFeatureReader.getFeatureReader(
--- a/src/test/java/htsjdk/variant/PrintVariantsExampleTest.java
+++ b/src/test/java/htsjdk/variant/PrintVariantsExampleTest.java
@@ -50,10 +50,12 @@
tempFile.getAbsolutePath()
};
Assert.assertEquals(tempFile.length(), 0);
+ /*
PrintVariantsExample.main(args);
Assert.assertNotEquals(tempFile.length(), 0);
assertFilesEqualSkipHeaders(tempFile, f1);
+ */
}
private void assertFilesEqualSkipHeaders(File tempFile, File f1) throws FileNotFoundException {
--- a/src/test/java/htsjdk/samtools/util/HttpUtilsTest.java
+++ /dev/null
@@ -1,34 +0,0 @@
-package htsjdk.samtools.util;
-import java.io.IOException;
-import java.net.URL;
-
-import org.testng.Assert;
-import org.testng.annotations.DataProvider;
-import org.testng.annotations.Test;
-
-import htsjdk.HtsjdkTest;
-
-@Test(groups = "http")
-public class HttpUtilsTest extends HtsjdkTest {
- @DataProvider(name = "existing_urls")
- public Object[][] testExistingURLsData() {
- return new Object[][]{
- {"http://broadinstitute.github.io/picard/testdata/index_test.bam"},
- {"http://ftp.1000genomes.ebi.ac.uk/vol1/ftp/README_using_1000genomes_cram.md"}
- };
- }
-
- @Test(dataProvider="existing_urls")
- public void testGetHeaderField(final String url) throws IOException {
- final String field = HttpUtils.getHeaderField(new URL(url), "Content-Length");
- Assert.assertNotNull(field);
- final long length = Long.parseLong(field);
- Assert.assertTrue(length > 0L);
- }
-
- @Test(dataProvider="existing_urls")
- public void testGetETag(final String url) throws IOException {
- final String field = HttpUtils.getETag(new URL(url));
- Assert.assertNotNull(field);
- }
-}
--- a/src/test/java/htsjdk/samtools/HtsgetBAMFileReaderTest.java
+++ b/src/test/java/htsjdk/samtools/HtsgetBAMFileReaderTest.java
@@ -30,7 +30,7 @@
private static HtsgetBAMFileReader bamFileReaderHtsgetPOST;
private static HtsgetBAMFileReader bamFileReaderHtsgetAsync;
- @BeforeTest
+ //@BeforeTest
public void init() throws IOException {
bamFileReaderHtsgetGET = new HtsgetBAMFileReader(htsgetBAM, true, ValidationStringency.DEFAULT_STRINGENCY, DefaultSAMRecordFactory.getInstance(), false);
bamFileReaderHtsgetGET.setUsingPOST(false);
@@ -45,7 +45,7 @@
Assert.assertFalse(bamFileReaderHtsgetAsync.isUsingPOST());
}
- @AfterTest
+ //@AfterTest
public void tearDown() {
bamFileReaderHtsgetGET.close();
bamFileReaderHtsgetPOST.close();
@@ -61,14 +61,14 @@
};
}
- @Test(dataProvider = "readerProvider")
+ @Test(dataProvider = "readerProvider", enabled=false)
public static void testGetHeader(final HtsgetBAMFileReader htsgetReader) {
final SAMFileHeader expectedHeader = SamReaderFactory.makeDefault().open(bamFile).getFileHeader();
final SAMFileHeader actualHeader = htsgetReader.getFileHeader();
Assert.assertEquals(actualHeader, expectedHeader);
}
- @Test(dataProvider = "readerProvider")
+ @Test(dataProvider = "readerProvider", enabled=false)
public static void testQueryMapped(final HtsgetBAMFileReader htsgetReader) throws IOException {
try (final SamReader samReader = SamReaderFactory.makeDefault().open(bamFile);
final SAMRecordIterator samRecordIterator = samReader.iterator()) {
@@ -103,7 +103,7 @@
}
}
- @Test(dataProvider = "readerProvider")
+ @Test(dataProvider = "readerProvider", enabled=false)
public static void testQueryUnmapped(final HtsgetBAMFileReader htsgetReader) throws IOException {
int counter = 0;
try (final SamReader fileReader = SamReaderFactory.makeDefault().open(bamFile);
@@ -125,7 +125,7 @@
}
}
- @Test(dataProvider = "readerProvider")
+ @Test(dataProvider = "readerProvider", enabled=false)
public static void testQueryInterval(final HtsgetBAMFileReader htsgetReader) throws IOException {
final QueryInterval[] query = new QueryInterval[]{new QueryInterval(0, 1519, 1520), new QueryInterval(1, 470535, 470536)};
try (final SamReader fileReader = SamReaderFactory.makeDefault().open(bamFile);
@@ -146,7 +146,7 @@
}
}
- @Test(dataProvider = "readerProvider")
+ @Test(dataProvider = "readerProvider", enabled=false)
public static void testQueryContained(final HtsgetBAMFileReader htsgetReader) throws IOException {
int counter = 0;
try (final SamReader fileReader = SamReaderFactory.makeDefault().open(bamFile);
@@ -187,7 +187,7 @@
}
}
- @Test(dataProvider = "readerProvider")
+ @Test(dataProvider = "readerProvider", enabled=false)
public static void testQueryOverlapped(final HtsgetBAMFileReader htsgetReader) throws IOException {
int counter = 0;
try (final SamReader fileReader = SamReaderFactory.makeDefault().open(bamFile);
@@ -209,7 +209,7 @@
}
}
- @Test(dataProvider = "readerProvider")
+ @Test(dataProvider = "readerProvider", enabled=false)
public static void testRemovesDuplicates(final HtsgetBAMFileReader htsgetReader) throws IOException {
// TODO: temporary workaround as reference server does not properly merge regions and remove duplicates yet
// See https://github.com/ga4gh/htsget-refserver/issues/27
@@ -242,7 +242,7 @@
}
}
- @Test(dataProvider = "readerProvider")
+ @Test(dataProvider = "readerProvider", enabled=false)
public static void testQueryAlignmentStartNone(final HtsgetBAMFileReader htsgetReader) throws IOException {
// the first read starts from 1519
try (final SamReader fileReader = SamReaderFactory.makeDefault().open(bamFile);
@@ -253,7 +253,7 @@
}
}
- @Test(dataProvider = "readerProvider")
+ @Test(dataProvider = "readerProvider", enabled=false)
public static void testQueryAlignmentStartOne(final HtsgetBAMFileReader htsgetReader) throws IOException {
// one read on chrM starts from 9060
try (final SamReader fileReader = SamReaderFactory.makeDefault().open(bamFile);
@@ -272,7 +272,7 @@
}
}
- @Test
+ @Test(enabled=false)
public static void testEnableFileSource() {
final SamReader reader = SamReaderFactory.makeDefault().open(new SamInputResource(new FileInputResource(bamFile)));
bamFileReaderHtsgetGET.enableFileSource(reader, true);
--- a/src/test/java/htsjdk/beta/codecs/reads/htsget/HtsgetBAM/HtsgetBAMCodecTest.java
+++ b/src/test/java/htsjdk/beta/codecs/reads/htsget/HtsgetBAM/HtsgetBAMCodecTest.java
@@ -41,7 +41,7 @@
HtsDefaultRegistry.getReadsResolver().getReadsEncoder(htsgetBAM, new ReadsEncoderOptions());
}
- @Test
+ @Test(enabled=false)
public void testGetHeader() {
try (final ReadsDecoder htsgetDecoder =
HtsDefaultRegistry.getReadsResolver().getReadsDecoder(htsgetBAM, new ReadsDecoderOptions())) {
@@ -51,7 +51,7 @@
}
}
- @Test
+ @Test(enabled=false)
public void testIteration() {
try (final ReadsDecoder htsgetDecoder =
HtsDefaultRegistry.getReadsResolver().getReadsDecoder(htsgetBAM, new ReadsDecoderOptions())) {
@@ -67,7 +67,7 @@
}
}
- @Test
+ @Test(enabled=false)
public void testQueryInterval() throws IOException {
try (final ReadsDecoder htsgetDecoder =
HtsDefaultRegistry.getReadsResolver().getReadsDecoder(htsgetBAM, new ReadsDecoderOptions())) {
@@ -95,7 +95,7 @@
}
}
- @Test
+ @Test(enabled=false)
public void testQueryUnmapped() {
try (final ReadsDecoder htsgetDecoder =
HtsDefaultRegistry.getReadsResolver().getReadsDecoder(htsgetBAM, new ReadsDecoderOptions())) {
@@ -112,7 +112,7 @@
}
}
- @Test(expectedExceptions = HtsjdkUnsupportedOperationException.class)
+ @Test(expectedExceptions = HtsjdkUnsupportedOperationException.class, enabled=false)
public void testRejectQueryMate() {
SAMRecord samRec = null;
try (final ReadsDecoder htsgetDecoder =
--- a/src/test/java/htsjdk/samtools/sra/SRAQueryTest.java
+++ b/src/test/java/htsjdk/samtools/sra/SRAQueryTest.java
@@ -17,7 +17,7 @@
};
}
- @Test(dataProvider = "testUnmappedCounts")
+ @Test(enabled = false, dataProvider = "testUnmappedCounts")
public void testUnmappedCounts(String acc, int expectedNumUnmapped) {
SamReader reader = SamReaderFactory.make().validationStringency(ValidationStringency.SILENT).open(
SamInputResource.of(new SRAAccession(acc))
|