Socket
Socket
Sign inDemoInstall

cgds

Package Overview
Dependencies
0
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.1.2 to 0.1.3

58

lib/cgds.js

@@ -36,9 +36,9 @@ "use strict";

toJSON = function (data) {
var lines, columns;
toJSON = function (data, callback) {
var lines, errorTerms, errorOccured, columns;
// Split lines.
lines = data.split(/\r?\n/);
// Drop comments.
// Drop comments and empty lines.
lines = lines.filter(function (line) {
if (line.charAt(0) === "#") {
if (line.charAt(0) === "#" || line === "") {
return false;

@@ -49,13 +49,29 @@ } else {

});
// Convert to JSON.
columns = lines.shift().split(/\t/);
lines = lines.map(function (line) {
var obj;
obj = {};
line.split(/\t/).forEach(function (column, idx) {
obj[columns[idx]] = column;
// If the first line starts with "Error: " or in some buggy cases with the whole
// error string after dropping the comments, then it is likely to be an error.
errorTerms = ["Error: ", "No genetic profile available for genetic_profile_id: "];
errorOccured = errorTerms.some(function (errorTerm) {
if (lines[0].lastIndexOf(errorTerm, 0) === 0) {
return true;
} else {
return false;
}
});
if (errorOccured === true) {
callback({
message: lines[0]
}, null);
} else {
// Convert to JSON.
columns = lines.shift().split(/\t/);
lines = lines.map(function (line) {
var obj;
obj = {};
line.split(/\t/).forEach(function (column, idx) {
obj[columns[idx]] = column;
});
return obj;
});
return obj;
});
return lines;
callback(null, lines);
}
};

@@ -81,3 +97,3 @@

get(this.url + "?cmd=getTypesOfCancer", this.proxy, function (err, res) {
callback(null, toJSON(res));
toJSON(res, callback);
});

@@ -91,3 +107,3 @@ };

get(this.url + "?cmd=getCancerStudies", this.proxy, function (err, res) {
callback(null, toJSON(res));
toJSON(res, callback);
});

@@ -104,3 +120,3 @@ };

get(this.url + "?cmd=getGeneticProfiles&cancer_study_id=" + cancerStudyId, this.proxy, function (err, res) {
callback(null, toJSON(res));
toJSON(res, callback);
});

@@ -117,3 +133,3 @@ };

get(this.url + "?cmd=getCaseLists&cancer_study_id=" + cancerStudyId, this.proxy, function (err, res) {
callback(null, toJSON(res));
toJSON(res, callback);
});

@@ -147,3 +163,3 @@ };

get(this.url + "?cmd=getProfileData&case_set_id=" + caseSetId + "&genetic_profile_id=" + geneticProfileId + "&gene_list=" + geneList, this.proxy, function (err, res) {
callback(null, toJSON(res));
toJSON(res, callback);
});

@@ -180,3 +196,3 @@ };

get(url, this.proxy, function (err, res) {
callback(null, toJSON(res));
toJSON(res, callback);
});

@@ -193,3 +209,3 @@ };

get(this.url + "?cmd=getClinicalData&case_set_id=" + caseSetId, this.proxy, function (err, res) {
callback(null, toJSON(res));
toJSON(res, callback);
});

@@ -196,0 +212,0 @@ };

{
"name": "cgds",
"description": "A module for querying the Cancer Genomics Data Server (CGDS).",
"version": "0.1.2",
"version": "0.1.3",
"author": {

@@ -6,0 +6,0 @@ "name": "Alexander Grüneberg",

@@ -50,3 +50,4 @@ var expect, CGDS;

cgds.getTypesOfCancer(function (err, res) {
expect(res).to.be.a(Array);
expect(err).to.be(null);
expect(res).to.be.an(Array);
expect(res.length).to.be.greaterThan(0);

@@ -70,3 +71,4 @@ expect(Object.keys(res[0])).to.eql(["type_of_cancer_id", "name"]);

cgds.getCancerStudies(function (err, res) {
expect(res).to.be.a(Array);
expect(err).to.be(null);
expect(res).to.be.an(Array);
expect(res.length).to.be.greaterThan(0);

@@ -96,5 +98,6 @@ expect(Object.keys(res[0])).to.eql(["cancer_study_id", "name", "description"]);

});
it("should return a JSON representation of a tab-delimited file with six columns", function (done) {
it("should return a JSON representation of a tab-delimited file with six columns for an existing cancer study", function (done) {
cgds.getGeneticProfiles("brca_tcga", function (err, res) {
expect(res).to.be.a(Array);
expect(err).to.be(null);
expect(res).to.be.an(Array);
expect(res.length).to.be.greaterThan(0);

@@ -105,2 +108,10 @@ expect(Object.keys(res[0])).to.eql(["genetic_profile_id", "genetic_profile_name", "genetic_profile_description", "cancer_study_id", "genetic_alteration_type", "show_profile_in_analysis_tab"]);

});
it("should return an error if the cancer study does not exist", function (done) {
cgds.getGeneticProfiles("foo", function (err, res) {
expect(err).to.not.be(null);
expect(err.message).to.be("Error: Problem when identifying a cancer study for the request.");
expect(res).to.be(null);
done();
});
});
});

@@ -125,5 +136,6 @@

});
it("should return a JSON representation of a tab-delimited file with five columns", function (done) {
it("should return a JSON representation of a tab-delimited file with five columns if cancer study exists", function (done) {
cgds.getCaseLists("brca_tcga", function (err, res) {
expect(res).to.be.a(Array);
expect(err).to.be(null);
expect(res).to.be.an(Array);
expect(res.length).to.be.greaterThan(0);

@@ -134,2 +146,10 @@ expect(Object.keys(res[0])).to.eql(["case_list_id", "case_list_name", "case_list_description", "cancer_study_id", "case_ids"]);

});
it("should return an error if the cancer study does not exist", function (done) {
cgds.getGeneticProfiles("foo", function (err, res) {
expect(err).to.not.be(null);
expect(err.message).to.be("Error: Problem when identifying a cancer study for the request.");
expect(res).to.be(null);
done();
});
});
});

@@ -176,3 +196,4 @@

cgds.getProfileData("brca_tcga_3way_complete", "brca_tcga_mutations", "TP53", function (err, res) {
expect(res).to.be.a(Array);
expect(err).to.be(null);
expect(res).to.be.an(Array);
expect(res.length).to.be.greaterThan(0);

@@ -192,3 +213,4 @@ expect(Object.keys(res[0])).to.contain("GENE_ID");

cgds.getProfileData("brca_tcga_3way_complete", "brca_tcga_mutations", ["TP53", "GATA3"], function (err, res) {
expect(res).to.be.a(Array);
expect(err).to.be(null);
expect(res).to.be.an(Array);
expect(res.length).to.be.greaterThan(0);

@@ -208,3 +230,4 @@ expect(Object.keys(res[0])).to.contain("GENE_ID");

cgds.getProfileData("brca_tcga_3way_complete", ["brca_tcga_mutations", "brca_tcga_log2CNA"], "TP53", function (err, res) {
expect(res).to.be.a(Array);
expect(err).to.be(null);
expect(res).to.be.an(Array);
expect(res.length).to.be.greaterThan(0);

@@ -228,3 +251,26 @@ expect(Object.keys(res[0])).to.contain("GENETIC_PROFILE_ID");

});
it("should return an error if the case set does not exist", function (done) {
cgds.getProfileData("foo", "brca_tcga_mutations", "TP53", function (err, res) {
expect(err).to.not.be(null);
expect(err.message).to.be("Error: Invalid case_set_id: foo.");
expect(res).to.be(null);
done();
});
});
it("should return an error if the genetic profile does not exist", function (done) {
cgds.getProfileData("brca_tcga_3way_complete", "foo", "TP53", function (err, res) {
expect(err).to.not.be(null);
expect(err.message).to.be("No genetic profile available for genetic_profile_id: foo.");
expect(res).to.be(null);
done();
});
});
it("should return an empty result if the gene does not exist", function (done) {
cgds.getProfileData("brca_tcga_3way_complete", "brca_tcga_mutations", "foo", function (err, res) {
expect(err).to.be(null);
expect(res).to.be.an(Array);
expect(res.length).to.be(0);
done();
});
});
});

@@ -259,3 +305,4 @@

cgds.getMutationData("brca_tcga_mutations", "TP53", function (err, res) {
expect(res).to.be.a(Array);
expect(err).to.be(null);
expect(res).to.be.an(Array);
expect(res.length).to.be.greaterThan(0);

@@ -268,3 +315,4 @@ expect(Object.keys(res[0])).to.eql(["entrez_gene_id", "gene_symbol", "case_id", "sequencing_center", "mutation_status", "mutation_type", "validation_status", "amino_acid_change", "functional_impact_score", "xvar_link", "xvar_link_pdb", "xvar_link_msa", "chr", "start_position", "end_position", "reference_allele", "variant_allele", "genetic_profile_id"]);

cgds.getMutationData("brca_tcga_mutations", ["TP53", "GATA3"], function (err, res) {
expect(res).to.be.a(Array);
expect(err).to.be(null);
expect(res).to.be.an(Array);
expect(res.length).to.be.greaterThan(0);

@@ -277,3 +325,4 @@ expect(Object.keys(res[0])).to.eql(["entrez_gene_id", "gene_symbol", "case_id", "sequencing_center", "mutation_status", "mutation_type", "validation_status", "amino_acid_change", "functional_impact_score", "xvar_link", "xvar_link_pdb", "xvar_link_msa", "chr", "start_position", "end_position", "reference_allele", "variant_allele", "genetic_profile_id"]);

cgds.getMutationData(["brca_tcga_mutations", "brca_tcga_log2CNA"], "TP53", function (err, res) {
expect(res).to.be.a(Array);
expect(err).to.be(null);
expect(res).to.be.an(Array);
expect(res.length).to.be.greaterThan(0);

@@ -286,3 +335,4 @@ expect(Object.keys(res[0])).to.eql(["entrez_gene_id", "gene_symbol", "case_id", "sequencing_center", "mutation_status", "mutation_type", "validation_status", "amino_acid_change", "functional_impact_score", "xvar_link", "xvar_link_pdb", "xvar_link_msa", "chr", "start_position", "end_position", "reference_allele", "variant_allele", "genetic_profile_id"]);

cgds.getMutationData(["brca_tcga_mutations", "brca_tcga_log2CNA"], ["TP53", "GATA3"], function (err, res) {
expect(res).to.be.a(Array);
expect(err).to.be(null);
expect(res).to.be.an(Array);
expect(res.length).to.be.greaterThan(0);

@@ -295,3 +345,4 @@ expect(Object.keys(res[0])).to.eql(["entrez_gene_id", "gene_symbol", "case_id", "sequencing_center", "mutation_status", "mutation_type", "validation_status", "amino_acid_change", "functional_impact_score", "xvar_link", "xvar_link_pdb", "xvar_link_msa", "chr", "start_position", "end_position", "reference_allele", "variant_allele", "genetic_profile_id"]);

cgds.getMutationData("brca_tcga_mutations", "TP53", "brca_tcga_3way_complete", function (err, res) {
expect(res).to.be.a(Array);
expect(err).to.be(null);
expect(res).to.be.an(Array);
expect(res.length).to.be.greaterThan(0);

@@ -302,2 +353,18 @@ expect(Object.keys(res[0])).to.eql(["entrez_gene_id", "gene_symbol", "case_id", "sequencing_center", "mutation_status", "mutation_type", "validation_status", "amino_acid_change", "functional_impact_score", "xvar_link", "xvar_link_pdb", "xvar_link_msa", "chr", "start_position", "end_position", "reference_allele", "variant_allele", "genetic_profile_id"]);

});
it("should return an error if the genetic profile id does not exist", function (done) {
cgds.getMutationData("foo", "TP53", function (err, res) {
expect(err).to.not.be(null);
expect(err.message).to.be("Error: Problem when identifying a cancer study for the request.");
expect(res).to.be(null);
done();
});
});
it("should return an empty result if the gene does not exist", function (done) {
cgds.getMutationData("brca_tcga_mutations", "foo", function (err, res) {
expect(err).to.be(null);
expect(res).to.be.an(Array);
expect(res.length).to.be(0);
done();
});
});
});

@@ -324,3 +391,3 @@

cgds.getClinicalData("brca_tcga_3way_complete", function (err, res) {
expect(res).to.be.a(Array);
expect(res).to.be.an(Array);
expect(res.length).to.be.greaterThan(0);

@@ -331,2 +398,10 @@ expect(Object.keys(res[0])).to.eql(["case_id", "overall_survival_months", "overall_survival_status", "disease_free_survival_months", "disease_free_survival_status", "age_at_diagnosis"]);

});
it("should return an error if the case set does not exist", function (done) {
cgds.getClinicalData("foo", function (err, res) {
expect(err).to.not.be(null);
expect(err.message).to.be("Error: Problem when identifying a cancer study for the request.");
expect(res).to.be(null);
done();
});
});
});

@@ -333,0 +408,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc