Skip to content

Commit

Permalink
Use new endpoint for fetching protein lengths
Browse files Browse the repository at this point in the history
  • Loading branch information
joshkh committed Jul 17, 2017
1 parent d62280b commit 44df041
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 15 deletions.
10 changes: 5 additions & 5 deletions dist/mi-model.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mi-model",
"version": "0.4.12",
"version": "0.4.13",
"description": "Model for representing Molecular Interaction data",
"main": "src/index.js",
"scripts": {
Expand Down
1 change: 0 additions & 1 deletion public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

var model;


$.get( "json/EBI-1202920.json", function( data ) {
model = new MIModel(data).load().then(function(m) {
window.m = m;
Expand Down
8 changes: 5 additions & 3 deletions src/models/Feature.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,17 @@ var Regions = require('./Region').Regions;

var Feature = Backbone.Model.extend({

initialize: function(attrs = {}) {
initialize: function(attrs) {

attrs = attrs || {}

var sequenceData = attrs.sequenceData;
var sequenceDataCol = new Regions();


if (attrs.sequenceData !== null && typeof attrs.sequenceData !== 'undefined') {
if (sequenceData !== null && typeof sequenceData !== 'undefined') {

var abc = _.map(attrs.sequenceData, function(s) {
var abc = _.map(sequenceData, function(s) {
s.feature = this;
return s;
}, this);
Expand Down
1 change: 0 additions & 1 deletion src/models/Interaction.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ var Interaction = Backbone.Model.extend({

initialize: function(participants) {


// Give each participant a reference back to this interaction
this.set("participants", new Participants(this.get("participants").map(function(participant){
participant.interaction = this;
Expand Down
19 changes: 15 additions & 4 deletions src/models/MIData.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ var Promise = require('promise');

var Data = Backbone.Model.extend({

uniprotUrl: "http://www.uniprot.org/uniprot/?format=json&columns=length,id&query=accession:",
// uniprotUrl: "http://www.uniprot.org/uniprot/?format=json&columns=length,id&query=accession:",
uniprotUrl: "https://www.ebi.ac.uk/proteins/api/proteins/",

defaults: {
interactors: new Interactors(),
Expand All @@ -18,6 +19,10 @@ var Data = Backbone.Model.extend({

initialize: function(data){

this.get("interactions").reset();
this.get("interactors").reset();


this.get("interactors").add(parse.interactors(data.data).map(function(interactor) {
interactor.midata = this;
return interactor;
Expand All @@ -41,11 +46,17 @@ var Data = Backbone.Model.extend({
// Fetch the lengths of our participants
var requests = this.get("interactors").map(function(i){

return $.get(this.uniprotUrl + i.get("identifier").id,
function(data) {
i.set("length", parseInt(data[0].length));
return $.ajax({
url: this.uniprotUrl + i.get("identifier").id,
type: "GET",
headers: {
"Accept": "application/json"
}
}).done(function(data) {
i.set("length", data.sequence.length);
});


}, this);


Expand Down

0 comments on commit 44df041

Please sign in to comment.