diff --git a/test/__snapshots__/indexedfile.test.ts.snap b/test/__snapshots__/indexedfile.test.ts.snap index 9a830e93..f7ec70ca 100644 --- a/test/__snapshots__/indexedfile.test.ts.snap +++ b/test/__snapshots__/indexedfile.test.ts.snap @@ -1677767,3 +1677767,414 @@ exports[`cram31 returns the correct sequence 1`] = ` "uniqueId": 843, } `; + +exports[`match samtools matches names given from samtools 1`] = ` +[ + "SRR396636.sra.82183", + "SRR396636.sra.897624", + "SRR396636.sra.626822", + "SRR396636.sra.38901", + "SRR396636.sra.674403", + "SRR396636.sra.1045612", + "SRR396636.sra.181279", + "SRR396636.sra.1715745", + "SRR396636.sra.1270900", + "SRR396636.sra.1013691", + "SRR396636.sra.1896022", + "SRR396636.sra.429808", + "SRR396636.sra.258066", + "SRR396636.sra.1310919", + "SRR396636.sra.1516521", + "SRR396636.sra.627892", + "SRR396636.sra.1264342", + "SRR396636.sra.7233", + "SRR396636.sra.322327", + "SRR396636.sra.1205063", + "SRR396636.sra.1117231", + "SRR396636.sra.894750", + "SRR396636.sra.1038930", + "SRR396636.sra.797353", + "SRR396636.sra.1904614", + "SRR396636.sra.1457591", + "SRR396636.sra.1447376", + "SRR396636.sra.355219", + "SRR396636.sra.384351", + "SRR396636.sra.1369540", + "SRR396636.sra.579503", + "SRR396636.sra.1077317", + "SRR396636.sra.1902087", + "SRR396636.sra.854866", + "SRR396636.sra.57286", + "SRR396636.sra.157168", + "SRR396636.sra.499633", + "SRR396636.sra.1384320", + "SRR396636.sra.706630", + "SRR396636.sra.499413", + "SRR396636.sra.986656", + "SRR396636.sra.386408", + "SRR396636.sra.1181765", + "SRR396636.sra.554738", + "SRR396636.sra.1227954", + "SRR396636.sra.1258806", + "SRR396636.sra.1904868", + "SRR396636.sra.503628", + "SRR396636.sra.20257", + "SRR396636.sra.746474", + "SRR396636.sra.768749", + "SRR396636.sra.1132315", + "SRR396636.sra.1622784", + "SRR396636.sra.145453", + "SRR396636.sra.941096", + "SRR396636.sra.1378694", + "SRR396636.sra.1615098", + "SRR396636.sra.375245", + "SRR396636.sra.779088", + "SRR396636.sra.1594803", + "SRR396636.sra.967117", + "SRR396636.sra.1524854", + "SRR396636.sra.1900379", + "SRR396636.sra.494829", + "SRR396636.sra.163376", + "SRR396636.sra.185254", + "SRR396636.sra.875667", + "SRR396636.sra.339294", + "SRR396636.sra.1301555", + "SRR396636.sra.1020804", + "SRR396636.sra.1886241", + "SRR396636.sra.3440", + "SRR396636.sra.92342", + "SRR396636.sra.683693", + "SRR396636.sra.1468441", + "SRR396636.sra.347785", + "SRR396636.sra.529657", + "SRR396636.sra.805621", + "SRR396636.sra.449965", + "SRR396636.sra.1466709", + "SRR396636.sra.1460498", + "SRR396636.sra.779088", + "SRR396636.sra.1350724", + "SRR396636.sra.108415", + "SRR396636.sra.33595", + "SRR396636.sra.1206201", + "SRR396636.sra.1366178", + "SRR396636.sra.158295", + "SRR396636.sra.1731503", + "SRR396636.sra.965960", + "SRR396636.sra.1048829", + "SRR396636.sra.1293219", + "SRR396636.sra.247052", + "SRR396636.sra.933930", + "SRR396636.sra.977222", + "SRR396636.sra.753395", + "SRR396636.sra.1446590", + "SRR396636.sra.323523", + "SRR396636.sra.1425241", + "SRR396636.sra.793919", + "SRR396636.sra.1591209", + "SRR396636.sra.1089164", + "SRR396636.sra.1398448", + "SRR396636.sra.951100", + "SRR396636.sra.706207", + "SRR396636.sra.1289307", + "SRR396636.sra.329741", + "SRR396636.sra.1129332", + "SRR396636.sra.427074", + "SRR396636.sra.1341450", + "SRR396636.sra.72531", + "SRR396636.sra.559197", + "SRR396636.sra.782767", + "SRR396636.sra.373928", + "SRR396636.sra.283245", + "SRR396636.sra.985901", + "SRR396636.sra.516962", + "SRR396636.sra.1049918", + "SRR396636.sra.1194537", + "SRR396636.sra.373043", + "SRR396636.sra.1023067", + "SRR396636.sra.882593", + "SRR396636.sra.917674", + "SRR396636.sra.1382503", + "SRR396636.sra.44141", + "SRR396636.sra.511322", + "SRR396636.sra.1610735", + "SRR396636.sra.1343288", + "SRR396636.sra.1735551", + "SRR396636.sra.142184", + "SRR396636.sra.264857", + "SRR396636.sra.349946", + "SRR396636.sra.1032269", + "SRR396636.sra.240435", + "SRR396636.sra.1089726", + "SRR396636.sra.1642729", + "SRR396636.sra.339294", + "SRR396636.sra.1615715", + "SRR396636.sra.928385", + "SRR396636.sra.1359722", + "SRR396636.sra.1804592", + "SRR396636.sra.318982", + "SRR396636.sra.99831", + "SRR396636.sra.598913", + "SRR396636.sra.1180771", + "SRR396636.sra.692962", + "SRR396636.sra.401865", + "SRR396636.sra.935470", + "SRR396636.sra.573409", + "SRR396636.sra.1777324", + "SRR396636.sra.650830", + "SRR396636.sra.1807284", + "SRR396636.sra.330478", + "SRR396636.sra.1903640", + "SRR396636.sra.33736", + "SRR396636.sra.1265853", + "SRR396636.sra.457062", + "SRR396636.sra.1682553", + "SRR396636.sra.617591", + "SRR396636.sra.1415368", + "SRR396636.sra.1101137", + "SRR396636.sra.678281", + "SRR396636.sra.863843", + "SRR396636.sra.1064897", + "SRR396636.sra.1424541", + "SRR396636.sra.694156", + "SRR396636.sra.1199498", + "SRR396636.sra.150889", + "SRR396636.sra.638136", + "SRR396636.sra.225782", + "SRR396636.sra.340982", + "SRR396636.sra.1273458", + "SRR396636.sra.425330", + "SRR396636.sra.1332496", + "SRR396636.sra.1261885", + "SRR396636.sra.1565190", + "SRR396636.sra.198015", + "SRR396636.sra.416809", + "SRR396636.sra.352126", + "SRR396636.sra.774429", + "SRR396636.sra.1068621", + "SRR396636.sra.870597", + "SRR396636.sra.1019791", + "SRR396636.sra.639740", + "SRR396636.sra.901953", + "SRR396636.sra.1727926", + "SRR396636.sra.1895720", + "SRR396636.sra.1391968", + "SRR396636.sra.43114", + "SRR396636.sra.611817", + "SRR396636.sra.1701133", + "SRR396636.sra.318771", + "SRR396636.sra.771836", + "SRR396636.sra.318771", + "SRR396636.sra.1868261", + "SRR396636.sra.25311", + "SRR396636.sra.1359085", + "SRR396636.sra.40136", + "SRR396636.sra.1167072", + "SRR396636.sra.1255146", + "SRR396636.sra.1753086", + "SRR396636.sra.511352", + "SRR396636.sra.1020911", + "SRR396636.sra.55625", + "SRR396636.sra.1464652", + "SRR396636.sra.337369", + "SRR396636.sra.924115", + "SRR396636.sra.1747493", + "SRR396636.sra.765561", + "SRR396636.sra.1003460", + "SRR396636.sra.1703469", + "SRR396636.sra.1840591", + "SRR396636.sra.1342406", + "SRR396636.sra.64097", + "SRR396636.sra.1352195", + "SRR396636.sra.1149722", + "SRR396636.sra.1178364", + "SRR396636.sra.540041", + "SRR396636.sra.614643", + "SRR396636.sra.1680729", + "SRR396636.sra.1227613", + "SRR396636.sra.796957", + "SRR396636.sra.886819", + "SRR396636.sra.1289100", + "SRR396636.sra.1717635", + "SRR396636.sra.831823", + "SRR396636.sra.464626", + "SRR396636.sra.175669", + "SRR396636.sra.19806", + "SRR396636.sra.1113762", + "SRR396636.sra.590781", + "SRR396636.sra.594937", + "SRR396636.sra.174159", + "SRR396636.sra.573443", + "SRR396636.sra.201265", + "SRR396636.sra.1813919", + "SRR396636.sra.1117231", + "SRR396636.sra.626822", + "SRR396636.sra.1398778", + "SRR396636.sra.1289065", + "SRR396636.sra.423932", + "SRR396636.sra.3440", + "SRR396636.sra.1461706", + "SRR396636.sra.474167", + "SRR396636.sra.1250239", + "SRR396636.sra.1648856", + "SRR396636.sra.399452", + "SRR396636.sra.255386", + "SRR396636.sra.661307", + "SRR396636.sra.1794301", + "SRR396636.sra.320097", + "SRR396636.sra.1384320", + "SRR396636.sra.620876", + "SRR396636.sra.849410", + "SRR396636.sra.1102641", + "SRR396636.sra.1842353", + "SRR396636.sra.1547108", + "SRR396636.sra.1616848", + "SRR396636.sra.507136", + "SRR396636.sra.1295193", + "SRR396636.sra.790086", + "SRR396636.sra.1718763", + "SRR396636.sra.494829", + "SRR396636.sra.1718763", + "SRR396636.sra.1333958", + "SRR396636.sra.323226", + "SRR396636.sra.1011832", + "SRR396636.sra.1368187", + "SRR396636.sra.873395", + "SRR396636.sra.1591209", + "SRR396636.sra.195475", + "SRR396636.sra.822865", + "SRR396636.sra.1301555", + "SRR396636.sra.469558", + "SRR396636.sra.1369540", + "SRR396636.sra.454912", + "SRR396636.sra.540349", + "SRR396636.sra.926546", + "SRR396636.sra.1173312", + "SRR396636.sra.1480434", + "SRR396636.sra.1876493", + "SRR396636.sra.1134126", + "SRR396636.sra.842644", + "SRR396636.sra.247052", + "SRR396636.sra.1571342", + "SRR396636.sra.411537", + "SRR396636.sra.1729372", + "SRR396636.sra.715685", + "SRR396636.sra.1321830", + "SRR396636.sra.423731", + "SRR396636.sra.409059", + "SRR396636.sra.371521", + "SRR396636.sra.1453204", + "SRR396636.sra.1545427", + "SRR396636.sra.471964", + "SRR396636.sra.1801681", + "SRR396636.sra.812801", + "SRR396636.sra.987490", + "SRR396636.sra.1350597", + "SRR396636.sra.1409813", + "SRR396636.sra.269061", + "SRR396636.sra.515010", + "SRR396636.sra.1222574", + "SRR396636.sra.1436940", + "SRR396636.sra.1820486", + "SRR396636.sra.1621691", + "SRR396636.sra.848332", + "SRR396636.sra.1524854", + "SRR396636.sra.1015863", + "SRR396636.sra.1301964", + "SRR396636.sra.3152", + "SRR396636.sra.401219", + "SRR396636.sra.242934", + "SRR396636.sra.1461706", + "SRR396636.sra.1103126", + "SRR396636.sra.286839", + "SRR396636.sra.1316985", + "SRR396636.sra.1487385", + "SRR396636.sra.33101", + "SRR396636.sra.968985", + "SRR396636.sra.1655480", + "SRR396636.sra.1339886", + "SRR396636.sra.1855650", + "SRR396636.sra.595190", + "SRR396636.sra.942190", + "SRR396636.sra.992823", + "SRR396636.sra.135838", + "SRR396636.sra.682653", + "SRR396636.sra.724553", + "SRR396636.sra.1303454", + "SRR396636.sra.614643", + "SRR396636.sra.505268", + "SRR396636.sra.537571", + "SRR396636.sra.430593", + "SRR396636.sra.1176032", + "SRR396636.sra.1232984", + "SRR396636.sra.1703469", + "SRR396636.sra.1052658", + "SRR396636.sra.1714827", + "SRR396636.sra.755536", + "SRR396636.sra.796224", + "SRR396636.sra.1776061", + "SRR396636.sra.519197", + "SRR396636.sra.658805", + "SRR396636.sra.630135", + "SRR396636.sra.754729", + "SRR396636.sra.837927", + "SRR396636.sra.611660", + "SRR396636.sra.754865", + "SRR396636.sra.1810143", + "SRR396636.sra.254916", + "SRR396636.sra.1301249", + "SRR396636.sra.1566421", + "SRR396636.sra.312040", + "SRR396636.sra.92138", + "SRR396636.sra.215542", + "SRR396636.sra.104783", + "SRR396636.sra.33736", + "SRR396636.sra.1054311", + "SRR396636.sra.635996", + "SRR396636.sra.1864622", + "SRR396636.sra.807703", + "SRR396636.sra.138292", + "SRR396636.sra.166407", + "SRR396636.sra.1869189", + "SRR396636.sra.1783043", + "SRR396636.sra.1902068", + "SRR396636.sra.793750", + "SRR396636.sra.1360568", + "SRR396636.sra.405289", + "SRR396636.sra.175802", + "SRR396636.sra.1399072", + "SRR396636.sra.1412675", + "SRR396636.sra.1531897", + "SRR396636.sra.856872", + "SRR396636.sra.318982", + "SRR396636.sra.799864", + "SRR396636.sra.403963", + "SRR396636.sra.1468441", + "SRR396636.sra.370702", + "SRR396636.sra.458134", + "SRR396636.sra.155792", + "SRR396636.sra.788873", + "SRR396636.sra.1828241", + "SRR396636.sra.500252", + "SRR396636.sra.361365", + "SRR396636.sra.1082435", + "SRR396636.sra.1206392", + "SRR396636.sra.1701133", + "SRR396636.sra.1180680", + "SRR396636.sra.50031", + "SRR396636.sra.317109", + "SRR396636.sra.633882", + "SRR396636.sra.1361910", + "SRR396636.sra.1716188", + "SRR396636.sra.1625216", + "SRR396636.sra.1227613", + "SRR396636.sra.1708208", + "SRR396636.sra.1281874", + "SRR396636.sra.1361460", + "SRR396636.sra.1571342", + "SRR396636.sra.871481", + "SRR396636.sra.372851", + "SRR396636.sra.1025308", + "SRR396636.sra.1509724", + "SRR396636.sra.464626", +] +`; diff --git a/test/indexedfile.test.ts b/test/indexedfile.test.ts index e9b6a7a1..a4db1453 100644 --- a/test/indexedfile.test.ts +++ b/test/indexedfile.test.ts @@ -219,9 +219,7 @@ describe('match samtools', () => { }) const features = await cram.getRecordsForRange(0, 25999, 26499) - - const featNames = await loadTestJSON('SRR396636.expected.names.json') - expect(features.map(f => f.readName)).toEqual(featNames) + expect(features.map(f => f.readName)).toMatchSnapshot() expect(features.length).toEqual(406) }) }) diff --git a/test/lib/util.ts b/test/lib/util.ts index d6955ba4..af2c9306 100644 --- a/test/lib/util.ts +++ b/test/lib/util.ts @@ -1,40 +1,13 @@ -//@ts-nocheck -const path = typeof __webpack_require__ !== 'function' ? require('path') : null // eslint-disable-line camelcase -const fs = typeof __webpack_require__ !== 'function' ? require('fs') : null // eslint-disable-line camelcase import { fromUrl } from '../../src/io' +import path from 'path' const dataDir = path && path.dirname(require.resolve('../data/xx.fa')) -function testDataUrl(filename) { +export function testDataUrl(filename: string) { return `file://${dataDir}/${filename}`.replace('#', '%23') } -function testDataFile(filename) { +export function testDataFile(filename: string) { const source = testDataUrl(filename) return fromUrl(source) } - -async function loadTestJSON(filename) { - const data = await testDataFile(`${filename}`).readFile() - const text = data.toString() - return JSON.parse(text) -} - -export function JsonClone(obj) { - return JSON.parse(JSON.stringify(obj)) -} - -const REWRITE_EXPECTED_DATA = - typeof process !== 'undefined' && - process.env.CRAMJS_REWRITE_EXPECTED_DATA && - process.env.CRAMJS_REWRITE_EXPECTED_DATA !== '0' && - process.env.CRAMJS_REWRITE_EXPECTED_DATA !== 'false' - -module.exports = { - testDataUrl, - testDataFile, - loadTestJSON, - JsonClone, - REWRITE_EXPECTED_DATA, - fs, -}