|
| 1 | +/** |
| 2 | + * Update deprecated fasta & index urls in the reference object. |
| 3 | + */ |
| 4 | + |
| 5 | +const isString = (x) => { |
| 6 | + return (x && typeof x === "string") || x instanceof String |
| 7 | +} |
| 8 | + |
| 9 | +/** |
| 10 | + * Replaces deprecated s3 fasta URLs with twoBitURLs. The purpose here is to rescue references from saved sessions |
| 11 | + * that contain pointers to deprectated IGV s3 buckets. These buckets will eventually be deleted |
| 12 | + * |
| 13 | + * @param reference |
| 14 | + */ |
| 15 | +function updateReference(reference) { |
| 16 | + |
| 17 | + if (!(requiresUpdate(reference) && updates[reference.id])) { |
| 18 | + return |
| 19 | + } |
| 20 | + |
| 21 | + const updatedReference = updates[reference.id] |
| 22 | + if (updatedReference) { |
| 23 | + delete reference.fastaURL |
| 24 | + if (reference.indexURL) delete reference.indexURL |
| 25 | + reference.twoBitURL = updatedReference.twoBitURL |
| 26 | + if (updatedReference.twoBitBptURL) reference.twoBitBptURL = updatedReference.twoBitBptURL |
| 27 | + if (updatedReference.chromSizesURL) reference.chromSizesURL = updatedReference.chromSizesURL |
| 28 | + } |
| 29 | +} |
| 30 | + |
| 31 | +function requiresUpdate(reference) { |
| 32 | + return isString(reference.fastaURL) && |
| 33 | + (reference.fastaURL.startsWith("https://igv.org") || |
| 34 | + ["igv.org.genomes", "igv.broadinstitute.org", "igv.genepattern.org", "igvdata.broadinstitute.org", |
| 35 | + "igv-genepattern-org"].some(bucket => reference.fastaURL.includes(bucket))) |
| 36 | +} |
| 37 | + |
| 38 | +const updates = { |
| 39 | + "hs1": { |
| 40 | + "twoBitURL": "https://hgdownload.soe.ucsc.edu/goldenPath/hs1/bigZips/hs1.2bit", |
| 41 | + "twoBitBptURL": "https://hgdownload.soe.ucsc.edu/goldenPath/hs1/bigZips/hs1.2bit.bpt", |
| 42 | + "chromSizesURL": "https://hgdownload.soe.ucsc.edu/goldenPath/hs1/bigZips/hs1.chrom.sizes.txt" |
| 43 | + }, |
| 44 | + "hg38": { |
| 45 | + "twoBitURL": "https://hgdownload.soe.ucsc.edu/goldenPath/hg38/bigZips/hg38.2bit", |
| 46 | + "chromSizesURL": "https://hgdownload.soe.ucsc.edu/goldenPath/hg38/bigZips/hg38.chrom.sizes" |
| 47 | + }, |
| 48 | + "hg19": { |
| 49 | + "twoBitURL": "https://hgdownload.soe.ucsc.edu/goldenPath/hg19/bigZips/hg19.2bit", |
| 50 | + "chromSizesURL": "https://hgdownload.soe.ucsc.edu/goldenPath/hg19/bigZips/hg19.chrom.sizes" |
| 51 | + }, |
| 52 | + "hg18": { |
| 53 | + "twoBitURL": "https://hgdownload.soe.ucsc.edu/goldenPath/hg18/bigZips/hg18.2bit", |
| 54 | + "chromSizesURL": "https://hgdownload.soe.ucsc.edu/goldenPath/hg18/bigZips/hg18.chrom.sizes" |
| 55 | + }, |
| 56 | + "mm39": { |
| 57 | + "twoBitURL": "https://hgdownload.soe.ucsc.edu/goldenPath/mm39/bigZips/mm39.2bit", |
| 58 | + "chromSizesURL": "https://hgdownload.soe.ucsc.edu/goldenPath/mm39/bigZips/mm39.chrom.sizes" |
| 59 | + }, |
| 60 | + "mm10": { |
| 61 | + "twoBitURL": "https://hgdownload.soe.ucsc.edu/goldenPath/mm10/bigZips/mm10.2bit", |
| 62 | + "chromSizesURL": "https://hgdownload.soe.ucsc.edu/goldenPath/mm10/bigZips/mm10.chrom.sizes" |
| 63 | + }, |
| 64 | + "mm9": { |
| 65 | + "twoBitURL": "https://hgdownload.soe.ucsc.edu/goldenPath/mm9/bigZips/mm9.2bit", |
| 66 | + "chromSizesURL": "https://hgdownload.soe.ucsc.edu/goldenPath/mm9/bigZips/mm9.chrom.sizes" |
| 67 | + }, |
| 68 | + "rn7": { |
| 69 | + "twoBitURL": "https://hgdownload.soe.ucsc.edu/hubs/GCF/015/227/675/GCF_015227675.2/GCF_015227675.2.2bit", |
| 70 | + "twoBitBptURL": "https://hgdownload.soe.ucsc.edu/hubs/GCF/015/227/675/GCF_015227675.2/GCF_015227675.2.2bit.bpt", |
| 71 | + "chromSizesURL": "https://hgdownload.soe.ucsc.edu/hubs/GCF/015/227/675/GCF_015227675.2/GCF_015227675.2.chrom.sizes.txt" |
| 72 | + }, |
| 73 | + "rn6": { |
| 74 | + "twoBitURL": "https://hgdownload.soe.ucsc.edu/hubs/GCF/000/001/895/GCF_000001895.5/GCF_000001895.5.2bit", |
| 75 | + "twoBitBptURL": "https://hgdownload.soe.ucsc.edu/hubs/GCF/000/001/895/GCF_000001895.5/GCF_000001895.5.2bit.bpt", |
| 76 | + "chromSizesURL": "https://hgdownload.soe.ucsc.edu/hubs/GCF/000/001/895/GCF_000001895.5/GCF_000001895.5.chrom.sizes.txt" |
| 77 | + }, |
| 78 | + "gorGor6": { |
| 79 | + "twoBitURL": "https://hgdownload.soe.ucsc.edu/goldenPath/gorGor6/bigZips/gorGor6.2bit", |
| 80 | + "chromSizesURL": "https://hgdownload.soe.ucsc.edu/goldenPath/gorGor6/bigZips/gorGor6.chrom.sizes" |
| 81 | + }, |
| 82 | + "gorGor4": { |
| 83 | + "twoBitURL": "https://hgdownload.soe.ucsc.edu/goldenPath/gorGor4/bigZips/gorGor4.2bit", |
| 84 | + "chromSizesURL": "https://hgdownload.soe.ucsc.edu/goldenPath/gorGor4/bigZips/gorGor4.chrom.sizes" |
| 85 | + }, |
| 86 | + "panTro6": { |
| 87 | + "twoBitURL": "https://hgdownload.soe.ucsc.edu/goldenPath/panTro6/bigZips/panTro6.2bit", |
| 88 | + "chromSizesURL": "https://hgdownload.soe.ucsc.edu/goldenPath/panTro6/bigZips/panTro6.chrom.sizes" |
| 89 | + }, |
| 90 | + "panTro5": { |
| 91 | + "twoBitURL": "https://hgdownload.soe.ucsc.edu/goldenPath/panTro5/bigZips/panTro5.2bit", |
| 92 | + "chromSizesURL": "https://hgdownload.soe.ucsc.edu/goldenPath/panTro5/bigZips/panTro5.chrom.sizes" |
| 93 | + }, |
| 94 | + "panTro4": { |
| 95 | + "twoBitURL": "https://hgdownload.soe.ucsc.edu/goldenPath/panTro4/bigZips/panTro4.2bit", |
| 96 | + "chromSizesURL": "https://hgdownload.soe.ucsc.edu/goldenPath/panTro4/bigZips/panTro4.chrom.sizes" |
| 97 | + }, |
| 98 | + "macFas5": { |
| 99 | + "twoBitURL": "https://hgdownload.soe.ucsc.edu/goldenPath/macFas5/bigZips/macFas5.2bit", |
| 100 | + "chromSizesURL": "https://hgdownload.soe.ucsc.edu/goldenPath/macFas5/bigZips/macFas5.chrom.sizes" |
| 101 | + }, |
| 102 | + "panPan2": { |
| 103 | + "twoBitURL": "https://hgdownload.soe.ucsc.edu/goldenPath/panPan2/bigZips/panPan2.2bit", |
| 104 | + "chromSizesURL": "https://hgdownload.soe.ucsc.edu/goldenPath/panPan2/bigZips/panPan2.chrom.sizes" |
| 105 | + }, |
| 106 | + "canFam6": { |
| 107 | + "twoBitURL": "https://hgdownload.soe.ucsc.edu/goldenPath/canFam6/bigZips/canFam6.2bit", |
| 108 | + "chromSizesURL": "https://hgdownload.soe.ucsc.edu/goldenPath/canFam6/bigZips/canFam6.chrom.sizes" |
| 109 | + }, |
| 110 | + "canFam5": { |
| 111 | + "twoBitURL": "https://hgdownload.soe.ucsc.edu/goldenPath/canFam5/bigZips/canFam5.2bit", |
| 112 | + "chromSizesURL": "https://hgdownload.soe.ucsc.edu/goldenPath/canFam5/bigZips/canFam5.chrom.sizes" |
| 113 | + }, |
| 114 | + "canFam4": { |
| 115 | + "twoBitURL": "https://hgdownload.soe.ucsc.edu/goldenPath/canFam4/bigZips/canFam4.2bit", |
| 116 | + "chromSizesURL": "https://hgdownload.soe.ucsc.edu/goldenPath/canFam4/bigZips/canFam4.chrom.sizes" |
| 117 | + }, |
| 118 | + "canFam3": { |
| 119 | + "twoBitURL": "https://hgdownload.soe.ucsc.edu/goldenPath/canFam3/bigZips/canFam3.2bit", |
| 120 | + "chromSizesURL": "https://hgdownload.soe.ucsc.edu/goldenPath/canFam3/bigZips/canFam3.chrom.sizes" |
| 121 | + }, |
| 122 | + "bosTau9": { |
| 123 | + "twoBitURL": "https://hgdownload.soe.ucsc.edu/goldenPath/bosTau9/bigZips/bosTau9.2bit", |
| 124 | + "chromSizesURL": "https://hgdownload.soe.ucsc.edu/goldenPath/bosTau9/bigZips/bosTau9.chrom.sizes" |
| 125 | + }, |
| 126 | + "bosTau8": { |
| 127 | + "twoBitURL": "https://hgdownload.soe.ucsc.edu/goldenPath/bosTau8/bigZips/bosTau8.2bit", |
| 128 | + "chromSizesURL": "https://hgdownload.soe.ucsc.edu/goldenPath/bosTau8/bigZips/bosTau8.chrom.sizes" |
| 129 | + }, |
| 130 | + "susScr11": { |
| 131 | + "twoBitURL": "https://hgdownload.soe.ucsc.edu/goldenPath/susScr11/bigZips/susScr11.2bit", |
| 132 | + "chromSizesURL": "https://hgdownload.soe.ucsc.edu/goldenPath/susScr11/bigZips/susScr11.chrom.sizes" |
| 133 | + }, |
| 134 | + "galGal6": { |
| 135 | + "twoBitURL": "https://hgdownload.soe.ucsc.edu/goldenPath/galGal6/bigZips/galGal6.2bit", |
| 136 | + "chromSizesURL": "https://hgdownload.soe.ucsc.edu/goldenPath/galGal6/bigZips/galGal6.chrom.sizes" |
| 137 | + }, |
| 138 | + "danRer11": { |
| 139 | + "twoBitURL": "https://hgdownload.soe.ucsc.edu/goldenPath/danRer11/bigZips/danRer11.2bit", |
| 140 | + "chromSizesURL": "https://hgdownload.soe.ucsc.edu/goldenPath/danRer11/bigZips/danRer11.chrom.sizes" |
| 141 | + }, |
| 142 | + "danRer10": { |
| 143 | + "twoBitURL": "https://hgdownload.soe.ucsc.edu/goldenPath/danRer10/bigZips/danRer10.2bit", |
| 144 | + "chromSizesURL": "https://hgdownload.soe.ucsc.edu/goldenPath/danRer10/bigZips/danRer10.chrom.sizes" |
| 145 | + }, |
| 146 | + "ce11": { |
| 147 | + "twoBitURL": "https://hgdownload.soe.ucsc.edu/goldenPath/ce11/bigZips/ce11.2bit", |
| 148 | + "chromSizesURL": "https://hgdownload.soe.ucsc.edu/goldenPath/ce11/bigZips/ce11.chrom.sizes" |
| 149 | + }, |
| 150 | + "dm6": { |
| 151 | + "twoBitURL": "https://hgdownload.soe.ucsc.edu/goldenPath/dm6/bigZips/dm6.2bit", |
| 152 | + "chromSizesURL": "https://hgdownload.soe.ucsc.edu/goldenPath/dm6/bigZips/dm6.chrom.sizes" |
| 153 | + }, |
| 154 | + "dm3": { |
| 155 | + "twoBitURL": "https://hgdownload.soe.ucsc.edu/goldenPath/dm3/bigZips/dm3.2bit", |
| 156 | + "chromSizesURL": "https://hgdownload.soe.ucsc.edu/goldenPath/dm3/bigZips/dm3.chrom.sizes" |
| 157 | + }, |
| 158 | + "sacCer3": { |
| 159 | + "twoBitURL": "https://hgdownload.soe.ucsc.edu/hubs/GCF/000/146/045/GCF_000146045.2/GCF_000146045.2.2bit", |
| 160 | + "twoBitBptURL": "https://hgdownload.soe.ucsc.edu/hubs/GCF/000/146/045/GCF_000146045.2/GCF_000146045.2.2bit.bpt", |
| 161 | + "chromSizesURL": "https://hgdownload.soe.ucsc.edu/hubs/GCF/000/146/045/GCF_000146045.2/GCF_000146045.2.chrom.sizes.txt" |
| 162 | + }, |
| 163 | + "GCF_000002945.1": { |
| 164 | + "twoBitURL": "https://hgdownload.soe.ucsc.edu/hubs/GCF/000/002/945/GCF_000002945.1/GCF_000002945.1.2bit", |
| 165 | + "twoBitBptURL": "https://hgdownload.soe.ucsc.edu/hubs/GCF/000/002/945/GCF_000002945.1/GCF_000002945.1.2bit.bpt", |
| 166 | + "chromSizesURL": "https://hgdownload.soe.ucsc.edu/hubs/GCF/000/002/945/GCF_000002945.1/GCF_000002945.1.chrom.sizes.txt" |
| 167 | + }, |
| 168 | + "GCF_009858895.2": { |
| 169 | + "twoBitURL": "https://hgdownload.soe.ucsc.edu/hubs/GCF/009/858/895/GCF_009858895.2/GCF_009858895.2.2bit", |
| 170 | + "twoBitBptURL": "https://hgdownload.soe.ucsc.edu/hubs/GCF/009/858/895/GCF_009858895.2/GCF_009858895.2.2bit.bpt", |
| 171 | + "chromSizesURL": "https://hgdownload.soe.ucsc.edu/hubs/GCF/009/858/895/GCF_009858895.2/GCF_009858895.2.chrom.sizes.txt" |
| 172 | + }, |
| 173 | + "tair10": { |
| 174 | + "twoBitURL": "https://hgdownload.soe.ucsc.edu/hubs/GCF/000/001/735/GCF_000001735.3/GCF_000001735.3.2bit", |
| 175 | + "chromSizesURL": "https://hgdownload.soe.ucsc.edu/hubs/GCF/000/001/735/GCF_000001735.3/GCF_000001735.3.chrom.sizes.txt" |
| 176 | + }, |
| 177 | + "GCA_000022165.1": { |
| 178 | + "twoBitURL": "https://hgdownload.soe.ucsc.edu/hubs/GCA/000/022/165/GCA_000022165.1/GCA_000022165.1.2bit", |
| 179 | + "twoBitBptURL": "https://hgdownload.soe.ucsc.edu/hubs/GCA/000/022/165/GCA_000022165.1/GCA_000022165.1.2bit.bpt", |
| 180 | + "chromSizesURL": "https://hgdownload.soe.ucsc.edu/hubs/GCA/000/022/165/GCA_000022165.1/GCA_000022165.1.chrom.sizes.txt" |
| 181 | + } |
| 182 | +} |
| 183 | + |
| 184 | +export {updateReference} |
| 185 | + |
0 commit comments