From cf57b1c2af9deb3bc2e6c72b5866cf25c0452f2f Mon Sep 17 00:00:00 2001 From: Joshua Heimbach Date: Mon, 23 Jan 2017 11:47:02 +0000 Subject: [PATCH] Prevent mapping over undefined variables --- package.json | 2 +- public/index.html | 2 +- public/json/EBI-10828997.json | 1 + public/json/EBI-11619951.json | 1 + src/models/Interaction.js | 12 ++++++++---- src/models/Participant.js | 10 ++++++---- 6 files changed, 18 insertions(+), 10 deletions(-) create mode 100644 public/json/EBI-10828997.json create mode 100644 public/json/EBI-11619951.json diff --git a/package.json b/package.json index 9226386..a1dab9b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "mi-model", - "version": "0.4.1", + "version": "0.4.4", "description": "Model for representing Molecular Interaction data", "main": "src/index.js", "scripts": { diff --git a/public/index.html b/public/index.html index c2ac277..bf463f1 100644 --- a/public/index.html +++ b/public/index.html @@ -12,7 +12,7 @@ var model; - $.get( "json/EBI-9082861.json", function( data ) { + $.get( "json/EBI-1202920.json", function( data ) { model = new MIModel(data).load().then(function(m) { console.log("model", m); diff --git a/public/json/EBI-10828997.json b/public/json/EBI-10828997.json new file mode 100644 index 0000000..848014b --- /dev/null +++ b/public/json/EBI-10828997.json @@ -0,0 +1 @@ +{"data":[{"object":"interactor","id":"uniprotkb_Q9UMX1","sequence":"MAELRPSGAPGPTAPPAPGPTAPPAFASLFPPGLHAIYGECRRLYPDQPNPLQVTAIVKYWLGGPDPLDYVSMYRNVGSPSANIPEHWHYISFGLSDLYGDNRVHEFTGTDGPSGFGFELTFRLKRETGESAPPTWPAELMQGLARYVFQSENTFCSGDHVSWHSPLDNSESRIQHMLLTEDPQMQPVQTPFGVVTFLQIVGVCTEELHSAQQWNGQGILELLRTVPIAGGPWLITDMRRGETIFEIDPHLQERVDKGIETDGSNLSGVSAKCAWDDLSRPPEDDEDSRSICIGTQPRRLSGKDTEQIRETLRRGLEINSKPVLPPINPQRQNGLAHDRAPSRKDSLESDSSTAIIPHELIRTRQLESVHLKFNQESGALIPLCLRGRLLHGRHFTYKSITGDMAITFVSTGVEGAFATEEHPYAAHGPWLQILLTEEFVEKMLEDLEDLTSPEEFKLPKEYSWPEKKLKVSILPDVVFDSPLH","type":{"id":"MI:0326","name":"protein"},"organism":{"taxid":"9606","common":"human","scientific":"Homo sapiens"},"identifier":{"db":"uniprotkb","id":"Q9UMX1"},"label":"sufu_human"},{"object":"interactor","id":"uniprotkb_P10071","sequence":"MEAQSHSSTTTEKKKVENSIVKCSTRTDVSEKAVASSTTSNEDESPGQTYHRERRNAITMQPQNVQGLSKVSEEPSTSSDERASLIKKEIHGSLPHVAEPSVPYRGTVFAMDPRNGYMEPHYHPPHLFPAFHPPVPIDARHHEGRYHYDPSPIPPLHMTSALSSSPTYPDLPFIRISPHRNPTAASESPFSPPHPYINPYMDYIRSLHSSPSLSMISATRGLSPTDAPHAGVSPAEYYHQMALLTGQRSPYADIIPSAATAGTGAIHMEYLHAMDSTRFSSPRLSARPSRKRTLSISPLSDHSFDLQTMIRTSPNSLVTILNNSRSSSSASGSYGHLSASAISPALSFTYSSAPVSLHMHQQILSRQQSLGSAFGHSPPLIHPAPTFPTQRPIPGIPTVLNPVQVSSGPSESSQNKPTSESAVSSTGDPMHNKRSKIKPDEDLPSPGARGQQEQPEGTTLVKEEGDKDESKQEPEVIYETNCHWEGCAREFDTQEQLVHHINNDHIHGEKKEFVCRWLDCSREQKPFKAQYMLVVHMRRHTGEKPHKCTFEGCTKAYSRLENLKTHLRSHTGEKPYVCEHEGCNKAFSNASDRAKHQNRTHSNEKPYVCKIPGCTKRYTDPSSLRKHVKTVHGPEAHVTKKQRGDIHPRPPPPRDSGSHSQSRSPGRPTQGALGEQQDLSNTTSKREECLQVKTVKAEKPMTSQPSPGGQSSCSSQQSPISNYSNSGLELPLTDGGSIGDLSAIDETPIMDSTISTATTALALQARRNPAGTKWMEHVKLERLKQVNGMFPRLNPILPPKAPAVSPLIGNGTQSNNTCSLGGPMTLLPGRSDLSGVDVTMLNMLNRRDSSASTISSAYLSSRRSSGISPCFSSRRSSEASQAEGRPQNVSVADSYDPISTDASRRSSEASQSDGLPSLLSLTPAQQYRLKAKYAAATGGPPPTPLPNMERMSLKTRLALLGDALEPGVALPPVHAPRRCSDGGAHGYGRRHLQPHDAPGHGVRRASDPVRTGSEGLALPRVPRFSSLSSCNPPAMATSAEKRSLVLQNYTRPEGGQSRNFHSSPCPPSITENVTLESLTMDADANLNDEDFLPDDVVQYLNSQNQAGYEQHFPSALPDDSKVPHGPGDFDAPGLPDSHAGQQFHALEQPCPEGSKTDLPIQWNEVSSGSADLSSSKLKCGPRPAVPQTRAFGFCNGMVVHPQNPLRSGPAGGYQTLGENSNPYGGPEHLMLHNSPGSGTSGNAFHEQPCKAPQYGNCLNRQPVAPGALDGACGAGIQASKLKSTPMQGSGGQLNFGLPVAPNESAGSMVNGMQNQDPVGQGYLAHQLLGDSMQHPGAGRPGQQMLGQISATSHINIYQGPESCLPGAHGMGSQPSSLAVVRGYQPCASFGGSRRQAMPRDSLALQSGQLSDTSQTCRVNGIKMEMKGQPHPLCSNLQNYSGQFYDQTVGFSQQDTKAGSFSISDASCLLQGTSAKNSELLSPGANQVTSTVDSLDSHDLEGVQIDFDAIIDDGDHSSLMSGALSPSIIQNLSHSSSRLTTPRASLPFPALSMSTTNMAIGDMSSLLTSLAEESKFLAVMQ","type":{"id":"MI:0326","name":"protein"},"organism":{"taxid":"9606","common":"human","scientific":"Homo sapiens"},"identifier":{"db":"uniprotkb","id":"P10071"},"label":"gli3_human"},{"object":"interaction","id":"wwpdb_4bld","interactionType":{"id":"MI:0407","name":"direct interaction"},"complexType":{"id":"MI:1302","name":"stable complex"},"evidenceType":{"id":"ECO:0000353","name":"physical interaction evidence used in manual assertion"},"organism":{"taxid":"9606","common":"human","scientific":"Homo sapiens"},"identifiers":[{"db":"wwpdb","id":"4bld"},{"db":"intact","id":"EBI-10828997"}],"participants":[{"id":"1","interactorRef":"uniprotkb_Q9UMX1","stoichiometry":"1","bioRole":{"id":"MI:0499","name":"unspecified role"},"features":[{"id":"2","name":"gli3 binding region","category":"otherFeatures","type":{"id":"MI:0442","name":"sufficient binding region"},"sequenceData":[{"pos":"361-483","interactorRef":"uniprotkb_Q9UMX1","participantRef":"1"},{"pos":"32-278","interactorRef":"uniprotkb_Q9UMX1","participantRef":"1"}],"linkedFeatures":["3"]}]},{"id":"4","interactorRef":"uniprotkb_P10071","stoichiometry":"1","bioRole":{"id":"MI:0499","name":"unspecified role"},"features":[{"id":"3","name":"sufu binding region","category":"otherFeatures","type":{"id":"MI:0442","name":"sufficient binding region"},"sequenceData":[{"pos":"328-344","interactorRef":"uniprotkb_P10071","participantRef":"4"}],"linkedFeatures":["2"]}]}]}]} diff --git a/public/json/EBI-11619951.json b/public/json/EBI-11619951.json new file mode 100644 index 0000000..6d38c5c --- /dev/null +++ b/public/json/EBI-11619951.json @@ -0,0 +1 @@ +{"data":[{"object":"interactor","id":"uniprotkb_Q9BSB4","sequence":"MNCRSEVLEVSVEGRQVEEAMLAVLHTVLLHRSTGKFHYKKEGTYSIGTVGTQDVDCDFIDFTYVRVSSEELDRALRKVVGEFKDALRNSGGDGLGQMSLEFYQKKKSRWPFSDECIPWEVWTVKVHVVALATEQERQICREKVGEKLCEKIINIVEVMNRHEYLPKMPTQSEVDNVFDTGLRDVQPYLYKISFQITDALGTSVTTTMRRLIKDTLAL","type":{"id":"MI:0326","name":"protein"},"organism":{"taxid":"9606","common":"human","scientific":"Homo sapiens"},"identifier":{"db":"uniprotkb","id":"Q9BSB4"},"label":"atga1_human"},{"object":"interactor","id":"uniprotkb_Q8TDY2","sequence":"MKLYVFLVNTGTTLTFDTELTVQTVADLKHAIQSKYKIAIQHQVLVVNGGECMAADRRVCTYSAGTDTNPIFLFNKEMILCDRPPAIPKTTFSTENDMEIKVEESLMMPAVFHTVASRTQLALEMYEVAKKLCSFCEGLVHDEHLQHQGWAAIMANLEDCSNSYQKLLFKFESIYSNYLQSIEDIKLKLTHLGTAVSVMAKIPLLEC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SLIAEQQTNFNTVLTREKMRKENIINDLSDKLKSTMQQQERDKDLIESLSEDRARLLEEKKKLEEEVSKLRSSSFVPSPYVATAPELYGACAPELPGESDRSAVETADEGRVDSAMETSMMSVQENIHMLSEEKQRIMLLERTLQLKEEENKRLNQRLMSQSMSSVSSRHSEKIAIRDFQVGDLVLIILDERHDNYVLFTVSPTLYFLHSESLPALDLKPGEGASGASRRPWVLGKVMEKEYCQAKKAQNRFKVPLGTKFYRVKAVSWNKKV","type":{"id":"MI:0326","name":"protein"},"organism":{"taxid":"9606","common":"human","scientific":"Homo sapiens"},"identifier":{"db":"uniprotkb","id":"Q8TDY2"},"label":"rbcc1_human"},{"object":"interactor","id":"uniprotkb_O75385","sequence":"MEPGRGGTETVGKFEFSRKDLIGHGAFAVVFKGRHREKHDLEVAVKCINKKNLAKSQTLLGKEIKILKELKHENIVALYDFQEMANSVYLVMEYCNGGDLADYLHAMRTLSEDTIRLFLQQIAGAMRLLHSKGIIHRDLKPQNILLSNPAGRRANPNSIRVKIADFGFARYLQSNMMAATLCGSPMYMAPEVIMSQHYDGKADLWSIGTIVYQCLTGKAPFQASSPQDLRLFYEKNKTLVPTIPRETSAPLRQLLLALLQRNHKDRMDFDEFFHHPFLDASPSVRKSPPVPVPSYPSSGSGSSSSSSSTSHLASPPSLGEMQQLQKTLASPADTAGFLHSSRDSGGSKDSSCDTDDFVMVPAQFPGDLVAEAPSAKPPPDSLMCSGSSLVASAGLESHGRTPSPSPPCSSSPSPSGRAGPFSSSRCGASVPIPVPTQVQNYQRIERNLQSPTQFQTPRSSAIRRSGSTSPLGFARASPSPPAHAEHGGVLARKMSLGGGRPYTPSPQVGTIPERPGWSGTPSPQGAEMRGGRSPRPGSSAPEHSPRTSGLGCRLHSAPNLSDLHVVRPKLPKPPTDPLGAVFSPPQASPPQPSHGLQSCRNLRGSPKLPDFLQRNPLPPILGSPTKAVPSFDFPKTPSSQNLLALLARQGVVMTPPRNRTLPDLSEVGPFHGQPLGPGLRPGEDPKGPFGRSFSTSRLTDLLLKAAFGTQAPDPGSTESLQEKPMEIAPSAGFGGSLHPGARAGGTSSPSPVVFTVGSPPSGSTPPQGPRTRMFSAGPTGSASSSARHLVPGPCSEAPAPELPAPGHGCSFADPITANLEGAVTFEAPDLPEETLMEQEHTEILRGLRFTLLFVQHVLEIAALKGSASEAAGGPEYQLQESVVADQISLLSREWGFAEQLVLYLKVAELLSSGLQSAIDQIRAGKLCLSSTVKQVVRRLNELYKASVVSCQGLSLRLQRFFLDKQRLLDRIHSITAERLIFSHAVQMVQSAALDEMFQHREGCVPRYHKALLLLEGLQHMLSDQADIENVTKCKLCIERRLSALLTGICA","type":{"id":"MI:0326","name":"protein"},"organism":{"taxid":"9606","common":"human","scientific":"Homo sapiens"},"identifier":{"db":"uniprotkb","id":"O75385"},"label":"ulk1_human"},{"object":"interactor","id":"uniprotkb_O75143","sequence":"METDLNSQDRKDLDKFIKFFALKTVQVIVQARLGEKICTRSSSSPTGSDWFNLAIKDIPEVTHEAKKALAGQLPAVGRSMCVEISLKTSEGDSMELEIWCLEMNEKCDKEIKVSYTVYNRLSLLLKSLLAITRVTPAYRLSRKQGHEYVILYRIYFGEVQLSGLGEGFQTVRVGTVGTPVGTITLSCAYRINLAFMSTRQFERTPPIMGIIIDHFVDRPYPSSSPMHPCNYRTAGEDTGVIYPSVEDSQEVCTTSFSTSPPSQLSSSRLSYQPAALGVGSADLAYPVVFAAGLNATHPHQLMVPGKEGGVPLAPNQPVHGTQADQERLATCTPSDRTHCAATPSSSEDTETVSNSSEGRASPHDVLETIFVRKVGAFVNKPINQVTLTSLDIPFAMFAPKNLELEDTDPMVNPPDSPETESPLQGSLHSDGSSGGSSGNTHDDFVMIDFKPAFSKDDILPMDLGTFYREFQNPPQLSSLSIDIGAQSMAEDLDSLPEKLAVHEKNVREFDAFVETLQ","type":{"id":"MI:0326","name":"protein"},"organism":{"taxid":"9606","common":"human","scientific":"Homo sapiens"},"identifier":{"db":"uniprotkb","id":"O75143"},"label":"atg13_human"},{"object":"interaction","id":"intenz_2.7.11.1","interactionType":{"id":"MI:0915","name":"physical association"},"complexType":{"id":"MI:1302","name":"stable complex"},"evidenceType":{"id":"ECO:0000353","name":"physical interaction evidence used in manual assertion"},"organism":{"taxid":"9606","common":"human","scientific":"Homo sapiens"},"identifiers":[{"db":"intenz","id":"2.7.11.1"},{"db":"reactome","id":"R-HSA-5672130"},{"db":"reactome","id":"R-HSA-5666059"},{"db":"intact","id":"EBI-11619951"}],"participants":[{"id":"1","interactorRef":"uniprotkb_Q9BSB4","bioRole":{"id":"MI:0499","name":"unspecified role"},"features":[{"id":"2","name":"atg13 binding region","category":"bindingSites","type":{"id":"MI:0117","name":"binding-associated region"},"sequenceData":[{"pos":"?-?","interactorRef":"uniprotkb_Q9BSB4","participantRef":"1"}],"linkedFeatures":["3"]}]},{"id":"4","interactorRef":"uniprotkb_Q8TDY2","bioRole":{"id":"MI:0499","name":"unspecified role"},"features":[{"id":"5","name":"ulk1 binding region","category":"bindingSites","type":{"id":"MI:0117","name":"binding-associated region"},"sequenceData":[{"pos":"?-?","interactorRef":"uniprotkb_Q8TDY2","participantRef":"4"}],"linkedFeatures":["6"]},{"id":"7","name":"atg13 binding region","category":"bindingSites","type":{"id":"MI:0117","name":"binding-associated region"},"sequenceData":[{"pos":"?-?","interactorRef":"uniprotkb_Q8TDY2","participantRef":"4"}],"linkedFeatures":["8"]}]},{"id":"9","interactorRef":"uniprotkb_O75385","bioRole":{"id":"MI:0501","name":"enzyme"},"features":[{"id":"6","name":"rb1cc1 binding region","category":"bindingSites","type":{"id":"MI:0117","name":"binding-associated region"},"sequenceData":[{"pos":"828-1050","interactorRef":"uniprotkb_O75385","participantRef":"9"}],"linkedFeatures":["5"],"InterPro":"IPR022708"},{"id":"10","name":"atg13 binding region","category":"bindingSites","type":{"id":"MI:0117","name":"binding-associated region"},"sequenceData":[{"pos":"828-1000","interactorRef":"uniprotkb_O75385","participantRef":"9"}],"linkedFeatures":["11"],"InterPro":"IPR022708"}]},{"id":"12","interactorRef":"uniprotkb_O75143","bioRole":{"id":"MI:0499","name":"unspecified role"},"features":[{"id":"11","name":"ulk1 binding region","category":"bindingSites","type":{"id":"MI:0117","name":"binding-associated region"},"sequenceData":[{"pos":"?-?","interactorRef":"uniprotkb_O75143","participantRef":"12"}],"linkedFeatures":["10"]},{"id":"3","name":"atg101 binding region","category":"bindingSites","type":{"id":"MI:0117","name":"binding-associated region"},"sequenceData":[{"pos":"?-?","interactorRef":"uniprotkb_O75143","participantRef":"12"}],"linkedFeatures":["2"]},{"id":"8","name":"rb1cc1 binding region","category":"bindingSites","type":{"id":"MI:0117","name":"binding-associated region"},"sequenceData":[{"pos":"?-?","interactorRef":"uniprotkb_O75143","participantRef":"12"}],"linkedFeatures":["7"]}]}]}]} diff --git a/src/models/Interaction.js b/src/models/Interaction.js index 3e84a5c..874e251 100644 --- a/src/models/Interaction.js +++ b/src/models/Interaction.js @@ -23,11 +23,15 @@ Interaction = Backbone.Model.extend({ }, this))); // Now that participants have been created, add the features to this interaction - this.get("participants").each(function(participant) { - participant.get("features").each(function(feature) { - this.get("features").add(feature); + try { + this.get("participants").each(function(participant) { + participant.get("features").each(function(feature) { + this.get("features").add(feature); + }, this); }, this); - }, this); + } catch (e) { + // No participants + } // Also, now that all features exist, link them to each other this.get("features").each(function(feature) { diff --git a/src/models/Participant.js b/src/models/Participant.js index fdc8203..29c1c07 100644 --- a/src/models/Participant.js +++ b/src/models/Participant.js @@ -12,10 +12,12 @@ Participant = Backbone.Model.extend({ .get("interactors") .get(this.get("interactorRef"))) - this.set("features", new Features(this.get("features").map(function(feature) { - feature.participant = this; - return feature; - }, this))); + if (this.get("features")) { + this.set("features", new Features(this.get("features").map(function(feature) { + feature.participant = this; + return feature; + }, this))); + } },