Skip to content

Commit

Permalink
added initial orig_id (#2010)
Browse files Browse the repository at this point in the history
* added initial orig_id

* orig_id being set properly during transfer

* simplified code

* storing orig_id correctly in the comments

* fixed alignment detection

* updated dock and set default

* fixed a selection error

* remove console log
  • Loading branch information
nathandunn committed Feb 12, 2019
1 parent 1a27486 commit da96cd1
Show file tree
Hide file tree
Showing 8 changed files with 98 additions and 87 deletions.
13 changes: 9 additions & 4 deletions client/apollo/js/JSONUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ JSONUtils.handleCigarSubFeatures = function(feature,type){

JSONUtils.isAlignment = function(feature){
try {
return feature.data.cigar !== undefined;
return feature.data && feature.data.cigar !== undefined;
} catch (e) {
console.error('Unable to process feature alignment. Assuming not an alignment',feature,e);
return false;
Expand Down Expand Up @@ -297,7 +297,6 @@ JSONUtils.generateSubFeaturesFromCigar = function(feature){
* currently, for features with lazy-loaded children, ignores children
*/
JSONUtils.createApolloFeature = function( jfeature, specified_type, useName, specified_subtype ) {
console.log('creating apollo feature',jfeature);
var diagnose = (JSONUtils.verbose_conversion && jfeature.children() && jfeature.children().length > 0);
if (diagnose) {
console.log("converting JBrowse feature to Apollo feture, specified type: " + specified_type);
Expand Down Expand Up @@ -350,8 +349,14 @@ JSONUtils.createApolloFeature = function( jfeature, specified_type, useName, spe
var name = jfeature.get('name');
if (useName) {
// using 'id' attribute in the absence of 'name' attribute
name !== undefined ? afeature.name = name : afeature.name = id;
if( name !== undefined ) {
afeature.name = name;
}
else{
afeature.name = id;
}
}
afeature.orig_id = id ;

/*
afeature.properties = [];
Expand Down Expand Up @@ -653,4 +658,4 @@ window.JSONUtils = JSONUtils;

return JSONUtils;

});
});
14 changes: 10 additions & 4 deletions client/apollo/js/View/Track/AnnotTrack.js
Original file line number Diff line number Diff line change
Expand Up @@ -1035,7 +1035,7 @@ define([
var subfeatures = [];
var strand;
var parentFeature;
var variantSelectionRecords = new Array();
var variantSelectionRecords = [];

for (var i in selection_records) {
var type = selection_records[i].feature.get("type").toUpperCase();
Expand Down Expand Up @@ -1110,6 +1110,7 @@ define([
if (!featureToAdd.get('name')) {
featureToAdd.set('name', featureToAdd.get('id'));
}
featureToAdd.set('orig_id', featureToAdd.get('id'));
featureToAdd.set("strand", strand);
var fmin;
var fmax;
Expand Down Expand Up @@ -1171,6 +1172,8 @@ define([

var afeat ;
featureToAdd = JSONUtils.handleCigarSubFeatures(featureToAdd,biotype);
console.log('adding',featureToAdd)

if(biotype === 'mRNA'){
featureToAdd = JSONUtils.handleCigarSubFeatures(featureToAdd,biotype);
afeat = JSONUtils.createApolloFeature(featureToAdd, biotype, true);
Expand Down Expand Up @@ -1228,7 +1231,6 @@ define([
}
});
this.openDialog("Confirm", content);
return;
}
else {
process();
Expand All @@ -1255,6 +1257,7 @@ define([
}
else {
var afeat = JSONUtils.createApolloVariant(dragfeat, true);
afeat.orig_id = dojo.clone(dragfeat.id);
featuresToAdd.push(afeat);

var postData = {
Expand Down Expand Up @@ -1318,12 +1321,14 @@ define([
featureToAdd.set("start", fmin);
featureToAdd.set("end", fmax);
var afeat = JSONUtils.createApolloFeature(featureToAdd, type, true, subfeatType);
console.log('created apollo feature',afeat)
if (topLevelType) {
var topLevel = new Object();
var topLevel = {};
topLevel.orig_id = dojo.clone(afeat.id);
topLevel.location = dojo.clone(afeat.location);
topLevel.type = dojo.clone(afeat.type);
topLevel.type.name = topLevelType;
topLevel.children = new Array();
topLevel.children = [];
topLevel.children.push(afeat);
afeat = topLevel;
}
Expand All @@ -1335,6 +1340,7 @@ define([
var afeat = JSONUtils.createApolloFeature(dragfeat, type, true, subfeatType);
if (topLevelType) {
var topLevel = new Object();
topLevel.orig_id = dojo.clone(afeat.id);
topLevel.location = dojo.clone(afeat.location);
topLevel.type = dojo.clone(afeat.type);
topLevel.type.name = topLevelType;
Expand Down
60 changes: 20 additions & 40 deletions client/apollo/js/View/Track/DraggableHTMLFeatures.js
Original file line number Diff line number Diff line change
Expand Up @@ -845,6 +845,10 @@ var draggableTrack = declare( HTMLFeatureTrack,
}
}
else if (event.altKey) {
if(feat.parent()===undefined){
// do nothing
}
else
if (already_selected) {
// select entire feature
selman.addToSelection({ feature: feat.parent(), track: this}, false);
Expand Down Expand Up @@ -1190,6 +1194,12 @@ var draggableTrack = declare( HTMLFeatureTrack,
// return this.getUiGenomeCoord(mouseEvent) - 1;
},

_handleSelectedFeatures: function(){
var selFeats = this.selectionManager.getSelectedFeatures();
this.selectionManager.clearSelection();
return selFeats;
},

_makeFeatureContextMenu: function( featDiv, menuTemplate ) {
var atrack = this.webapollo.getAnnotTrack();

Expand All @@ -1211,91 +1221,61 @@ var draggableTrack = declare( HTMLFeatureTrack,
createAnnotationMenu.addChild(new dijitMenuItem( {
label: "pseudogene",
onClick: dojo.hitch(this, function() {
var selection = this.selectionManager.getSelection();
var selFeats = this.selectionManager.getSelectedFeatures();
this.selectionManager.clearSelection();
atrack.createGenericAnnotations(selFeats, "transcript", null, "pseudogene");
atrack.createGenericAnnotations(this._handleSelectedFeatures(), "transcript", null, "pseudogene");
})
}));
createAnnotationMenu.addChild(new dijitMenuItem( {
label: "tRNA",
onClick: dojo.hitch(this, function() {
var selection = this.selectionManager.getSelection();
var selFeats = this.selectionManager.getSelectedFeatures();
this.selectionManager.clearSelection();
atrack.createGenericAnnotations(selFeats, "tRNA", null, "gene");
atrack.createGenericAnnotations(this._handleSelectedFeatures(), "tRNA", null, "gene");
})
}));
createAnnotationMenu.addChild(new dijitMenuItem( {
label: "snRNA",
onClick: dojo.hitch(this, function() {
var selection = this.selectionManager.getSelection();
var selFeats = this.selectionManager.getSelectedFeatures();
this.selectionManager.clearSelection();
atrack.createGenericAnnotations(selFeats, "snRNA", null, "gene");
atrack.createGenericAnnotations(this._handleSelectedFeatures(), "snRNA", null, "gene");
})
}));
createAnnotationMenu.addChild(new dijitMenuItem( {
label: "snoRNA",
onClick: dojo.hitch(this, function() {
var selection = this.selectionManager.getSelection();
var selFeats = this.selectionManager.getSelectedFeatures();
this.selectionManager.clearSelection();
atrack.createGenericAnnotations(selFeats, "snoRNA", null, "gene");
atrack.createGenericAnnotations(this._handleSelectedFeatures(), "snoRNA", null, "gene");
})
}));
createAnnotationMenu.addChild(new dijitMenuItem( {
label: "ncRNA",
onClick: dojo.hitch(this, function() {
var selection = this.selectionManager.getSelection();
var selFeats = this.selectionManager.getSelectedFeatures();
this.selectionManager.clearSelection();
atrack.createGenericAnnotations(selFeats, "ncRNA", null, "gene");
atrack.createGenericAnnotations(this._handleSelectedFeatures(), "ncRNA", null, "gene");
})
}));
createAnnotationMenu.addChild(new dijitMenuItem( {
label: "rRNA",
onClick: dojo.hitch(this, function() {
var selection = this.selectionManager.getSelection();
var selFeats = this.selectionManager.getSelectedFeatures();
this.selectionManager.clearSelection();
atrack.createGenericAnnotations(selFeats, "rRNA", null, "gene");
atrack.createGenericAnnotations(this._handleSelectedFeatures(), "rRNA", null, "gene");
})
}));
createAnnotationMenu.addChild(new dijitMenuItem( {
label: "miRNA",
onClick: dojo.hitch(this, function() {
var selection = this.selectionManager.getSelection();
var selFeats = this.selectionManager.getSelectedFeatures();
this.selectionManager.clearSelection();
atrack.createGenericAnnotations(selFeats, "miRNA", null, "gene");
atrack.createGenericAnnotations(this._handleSelectedFeatures(), "miRNA", null, "gene");
})
}));
createAnnotationMenu.addChild(new dijitMenuItem( {
label: "repeat_region",
onClick: dojo.hitch(this, function() {
var selection = this.selectionManager.getSelection();
var selFeats = this.selectionManager.getSelectedFeatures();
this.selectionManager.clearSelection();
atrack.createGenericOneLevelAnnotations(selFeats, "repeat_region", true);
atrack.createGenericOneLevelAnnotations(this._handleSelectedFeatures(), "repeat_region", true);
})
}));
createAnnotationMenu.addChild(new dijitMenuItem( {
label: "terminator",
onClick: dojo.hitch(this, function() {
var selection = this.selectionManager.getSelection();
var selFeats = this.selectionManager.getSelectedFeatures();
this.selectionManager.clearSelection();
atrack.createGenericOneLevelAnnotations(selFeats, "terminator", false);
atrack.createGenericOneLevelAnnotations(this._handleSelectedFeatures(), "terminator", false);
})
}));
createAnnotationMenu.addChild(new dijitMenuItem( {
label: "transposable_element",
onClick: dojo.hitch(this, function() {
var selection = this.selectionManager.getSelection();
var selFeats = this.selectionManager.getSelectedFeatures();
this.selectionManager.clearSelection();
atrack.createGenericOneLevelAnnotations(selFeats, "transposable_element", true);
atrack.createGenericOneLevelAnnotations(this._handleSelectedFeatures(), "transposable_element", true);
})
}));

Expand Down
82 changes: 43 additions & 39 deletions docs/Configure.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,46 +18,44 @@ that are defined in the Config.groovy file:
```
// default apollo settings
apollo {
default_minimum_intron_size = 1
history_size = 0
overlapper_class = "org.bbop.apollo.sequence.OrfOverlapper"
track_name_comparator = "/config/track_name_comparator.js"
use_cds_for_new_transcripts = true
user_pure_memory_store = true
translation_table = "/config/translation_tables/ncbi_1_translation_table.txt"
is_partial_translation_allowed = false // unused so far
get_translation_code = 1
only_owners_delete = false
sequence_search_tools = [
blat_nuc: [
search_exe: "/usr/local/bin/blat",
search_class: "org.bbop.apollo.sequence.search.blat.BlatCommandLineNucleotideToNucleotide",
name: "Blat nucleotide",
params: ""
],
blat_prot: [
search_exe: "/usr/local/bin/blat",
search_class: "org.bbop.apollo.sequence.search.blat.BlatCommandLineProteinToNucleotide",
name: "Blat protein",
params: ""
// other translation codes are of the form ncbi_KEY_translation_table.txt
// under the web-app/translation_tables directory
// to add your own add them to that directory and over-ride the translation code here
get_translation_code = 1
proxies = [
[
referenceUrl : 'http://golr.geneontology.org/select',
targetUrl : 'http://golr.geneontology.org/solr/select',
active : true,
fallbackOrder: 0,
replace : true
]
,
[
referenceUrl : 'http://golr.geneontology.org/select',
targetUrl : 'http://golr.berkeleybop.org/solr/select',
active : false,
fallbackOrder: 1,
replace : false
]
]
]
splice_donor_sites = [ "GT" ]
splice_acceptor_sites = [ "AG"]
gff3.source= "."
bootstrap = false
info_editor = {
feature_types = "default"
attributes = true
dbxrefs = true
pubmed_ids = true
go_ids = true
comments = true
}
sequence_search_tools = [
blat_nuc : [
search_exe : "/usr/local/bin/blat",
search_class: "org.bbop.apollo.sequence.search.blat.BlatCommandLineNucleotideToNucleotide",
name : "Blat nucleotide",
params : ""
],
blat_prot: [
search_exe : "/usr/local/bin/blat",
search_class: "org.bbop.apollo.sequence.search.blat.BlatCommandLineProteinToNucleotide",
name : "Blat protein",
params : ""
//tmp_dir: "/opt/apollo/tmp" optional param
]
]
...
}
```

Expand Down Expand Up @@ -157,6 +155,12 @@ Additional links for log4j:
http://blog.andresteingress.com/2012/03/22/grails-adding-more-than-one-log4j-configurations/
- Grails log4j guide: http://grails.github.io/grails-doc/2.4.x/guide/single.html#logging

### Add attribute for the original id of the object

In the apollo config override set `store_orig_id=true` to store an `orid_id` attribute on the top-level feature that
represents the original id from the genomic evidence. This is useful for re-merging code as Apollo will generate its own IDs because
annotations will be based on multiple evidence sources.


### Canned Elements

Expand Down
1 change: 1 addition & 0 deletions grails-app/conf/Config.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ apollo {
user_pure_memory_store = true
is_partial_translation_allowed = false // unused so far
export_subfeature_attrs = false
store_orig_id = false // sets the orig_id to the original evidence id when first created

// used for uploading
common_data_directory = "/opt/apollo"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,10 @@ class ConfigWrapperService {
grailsApplication.config.apollo.authentications
}

def storeOrigId() {
grailsApplication.config.apollo.store_orig_id
}

def getPingUrl() {
Boolean phoneHome = grailsApplication.config.apollo.phone.phoneHome
if(phoneHome){
Expand Down
10 changes: 10 additions & 0 deletions grails-app/services/org/bbop/apollo/FeatureService.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -1423,6 +1423,16 @@ public void setTranslationEnd(Transcript transcript, int translationEnd) {
} else {
gsolFeature.setLastUpdated(new Date());
}
if(configWrapperService.storeOrigId()){
if (jsonFeature.has(FeatureStringEnum.ORIG_ID.value)) {
FeatureProperty gsolProperty = new FeatureProperty()
gsolProperty.setTag(FeatureStringEnum.ORIG_ID.value)
gsolProperty.setValue(jsonFeature.get(FeatureStringEnum.ORIG_ID.value))
gsolProperty.setFeature(gsolFeature)
gsolProperty.save()
gsolFeature.addToFeatureProperties(gsolProperty)
}
}
if (jsonFeature.has(FeatureStringEnum.PROPERTIES.value)) {
JSONArray properties = jsonFeature.getJSONArray(FeatureStringEnum.PROPERTIES.value);
for (int i = 0; i < properties.length(); ++i) {
Expand Down
1 change: 1 addition & 0 deletions src/gwt/org/bbop/apollo/gwt/shared/FeatureStringEnum.java
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ public enum FeatureStringEnum {
VARIANT_INFO,
OLD_VARIANT_INFO,
NEW_VARIANT_INFO,
ORIG_ID,
;


Expand Down

0 comments on commit da96cd1

Please sign in to comment.