-
Notifications
You must be signed in to change notification settings - Fork 199
/
FastaFileDialog.js
96 lines (83 loc) · 3.45 KB
/
FastaFileDialog.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
define( [
'dojo/_base/declare',
'dijit/form/Button',
'dijit/form/RadioButton',
'dojo/dom-construct',
'JBrowse/View/FileDialog',
'./FileDialog/TrackList/BgzipIndexedFASTADriver',
'./FileDialog/TrackList/IndexedFASTADriver',
'./FileDialog/TrackList/TwoBitDriver',
'./FileDialog/TrackList/ChromSizesDriver'
],
function(
declare,
Button,
RadioButton,
dom,
FileDialog,
BgzipIndexedFASTADriver,
IndexedFASTADriver,
TwoBitDriver,
ChromSizesDriver
) {
return declare( FileDialog, {
constructor: function( args ) {
this.inherited(arguments);
this._fileTypeDrivers = [ new BgzipIndexedFASTADriver(), new IndexedFASTADriver(), new TwoBitDriver(), new ChromSizesDriver() ];
return this;
},
show: function( args ) {
args.introMsg = "Select a FASTA file (.fa), indexed FASTA (.fa and .fai), bgzip indexed FASTA (.fa, .fai, and .gzi), twobit (.2bit) file, or a chrom.sizes file (tab separated refseq name and length)";
this.inherited(arguments);
this.dialog.set('title', 'Open sequence file');
},
_makeActionBar: function( openCallback, cancelCallback ) {
var actionBar = dom.create(
'div', {
className: 'dijitDialogPaneActionBar'
});
var disChoices = this.refSeqOrderChoice = [
new RadioButton({ id: 'sortAlpha',
value: 'sortAlpha',
checked: true
}),
new RadioButton({ id: 'sortLength',
value: 'sortLength'
}),
new RadioButton({ id: 'noSort',
value: 'noSort'
})
];
var aux = dom.create('div',{className:'aux'},actionBar);
disChoices[0].placeAt(aux);
dom.create('label', { "for": 'sortAlpha', innerHTML: 'Sort refseqs by name' }, aux ),
disChoices[1].placeAt(aux);
dom.create('label', { "for": 'sortLength', innerHTML: 'Sort refseqs by length' }, aux );
disChoices[2].placeAt(aux);
dom.create('label', { "for": 'noSort', innerHTML: 'Use order from file' }, aux );
new Button({ iconClass: 'dijitIconDelete', label: 'Cancel',
onClick: dojo.hitch( this, function() {
cancelCallback && cancelCallback();
this.dialog.hide();
})
})
.placeAt( actionBar );
new Button({
iconClass: 'dijitIconFolderOpen',
label: 'Open',
onClick: () => {
if (openCallback) {
openCallback({
trackConfs: this.trackList.getTrackConfigurations(),
refSeqOrder: this.refSeqOrderChoice[0].checked ? "alphabetic descending" :
this.refSeqOrderChoice[1].checked ? "length descending" :
undefined
}).then( () => this.dialog.hide(), err => { console.error(err) } )
}
}
})
.placeAt( actionBar );
return { domNode: actionBar };
}
});
});