Skip to content

Commit

Permalink
Merge pull request #1074 from nci-hcmi-catalog/develop
Browse files Browse the repository at this point in the history
🔖 Release 1.24.0
  • Loading branch information
mistryrn authored Jul 10, 2024
2 parents 11b67a2 + 51a9982 commit cd00c27
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 3 deletions.
4 changes: 1 addition & 3 deletions cms/src/helpers/genomicVariants.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,7 @@ const buildVariantId = ({

const buildModelUrl = caseId => `${BASE_GDC_URL}/cases/${caseId}`;
const buildMafUrl = fileId => `${BASE_GDC_URL}/files/${fileId}`;
// URL encoded: /v1/repository?facetTab=files&filters={"op":"and","content":[{"op":"in","content":{"field":"cases.case_id","value":["caseId"]}}]}&searchTableTab=files
const buildSequenceUrl = caseId =>
`${BASE_GDC_URL}/v1/repository?facetTab=files&filters=%7B%22op%22%3A%22and%22%2C%22content%22%3A%5B%7B%22op%22%3A%22in%22%2C%22content%22%3A%7B%22field%22%3A%22cases.case_id%22%2C%22value%22%3A%5B%22${caseId}%22%5D%7D%7D%5D%7D&searchTableTab=files`;
const buildSequenceUrl = caseId => `${BASE_GDC_URL}/cases/${caseId}#files`;

export const addGenomicVariantsFromMaf = async (name, mafData, { filename, fileId }, caseId) => {
const model = await Model.findOne({ name });
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
const OLD_URL_PATTERN = /https:\/\/portal\.gdc\.cancer\.gov\/v1\/repository\?facetTab=files&filters=%7B%22op%22%3A%22and%22%2C%22content%22%3A%5B%7B%22op%22%3A%22in%22%2C%22content%22%3A%7B%22field%22%3A%22cases\.case_id%22%2C%22value%22%3A%5B%22(.*?)%22%5D%7D%7D%5D%7D&searchTableTab=files/;
const NEW_URL_PATTERN = /https:\/\/portal\.gdc\.cancer\.gov\/cases\/(.*?)#files/;

module.exports = {
async up(db) {
const collection = db.collection('models');

const cursor = collection.find({
source_sequence_url: {
$regex: OLD_URL_PATTERN,
},
});

while (await cursor.hasNext()) {
const doc = await cursor.next();
const match = doc.source_sequence_url.match(OLD_URL_PATTERN);

if (match) {
const caseId = match[1];
const newUrl = `https://portal.gdc.cancer.gov/cases/${caseId}#files`;

await collection.updateOne({ _id: doc._id }, { $set: { source_sequence_url: newUrl } });
}
}
},
async down(db) {
const collection = db.collection('models');

const cursor = collection.find({
source_sequence_url: {
$regex: NEW_URL_PATTERN,
},
});

while (await cursor.hasNext()) {
const doc = await cursor.next();
const match = doc.source_sequence_url.match(NEW_URL_PATTERN);

if (match) {
const caseId = match[1];
const newUrl = `https://portal.gdc.cancer.gov/v1/repository?facetTab=files&filters=%7B%22op%22%3A%22and%22%2C%22content%22%3A%5B%7B%22op%22%3A%22in%22%2C%22content%22%3A%7B%22field%22%3A%22cases.case_id%22%2C%22value%22%3A%5B%22${caseId}%22%5D%7D%7D%5D%7D&searchTableTab=files`;

await collection.updateOne({ _id: doc._id }, { $set: { source_sequence_url: newUrl } });
}
}
},
};

0 comments on commit cd00c27

Please sign in to comment.