sequenceserver
sequenceserver copied to clipboard
Downloads of HSP alignments - slight reformatting
- [ ] they should indicate a, b, c letters like so "-hit_1_hsp_c" (after the coordinate)
- [ ] they should have whitespace (one newline) between HSPs
Getting the "hsp_a" part is pretty straight forward. Right now I am a bit struggling to call hit.number for the specific hit. My Javascript is not that good, but in other files it is simply used and I get the error of hit being undefined.
Could anybody may offer some assistance for that, maybe @Lazy-poet, @yeban?
for now its:
generate_fasta(hsps) {
var fasta = '';
_.each(hsps, _.bind(function (hsp) {
fasta += '>'+hsp.query_id+':'+hsp.qstart+'-'+hsp.qend+'-hit_'+'???'+'_hsp_'+toLetters(hsp.number)+'\n';
fasta += hsp.qseq+'\n';
fasta += '>'+hsp.query_id+':'+hsp.qstart+'-'+hsp.qend+'-hit_'+'???'+'_hsp_'+toLetters(hsp.number)+
'_alignment_'+hsp.hit_id+':'+hsp.sstart+'-'+hsp.send+'\n';
fasta += hsp.midline+'\n';
fasta += '>'+hsp.hit_id+':'+hsp.sstart+'-'+hsp.send+'-hit_'+'???'+'_hsp_'+toLetters(hsp.number)+'\n';
fasta += hsp.sseq+'\n\n';
}, this));
return fasta;
}`
And I also tried something like that:
generate_fasta() {
var fasta = '';
this.props.queries.forEach(
(query) => query.hits.forEach(
(hit) => {
num_hits++;
_.each(hsps, _.bind(function (hsp) {
fasta += '>'+hsp.query_id+':'+hsp.qstart+'-'+hsp.qend+'-hit_'+hit.number+'_hsp_'+toLetters(hsp.number)+'\n';
fasta += hsp.qseq+'\n';
fasta += '>'+hsp.query_id+':'+hsp.qstart+'-'+hsp.qend+'hit_'+hit.number+'_hsp_'+toLetters(hsp.number)+
'_alignment_'+hsp.hit_id+':'+hsp.sstart+'-'+hsp.send+'\n';
fasta += hsp.midline+'\n';
fasta += '>'+hsp.hit_id+':'+hsp.sstart+'-'+hsp.send+'hit_'+hit.number+'_hsp_'+toLetters(hsp.number)+'\n';
fasta += hsp.sseq+'\n\n';
}));
}
))
;
return fasta
}
The problem is that it cannot read properties of data (and I guess everything after that as well). So I tried to add properties to the constructer and extend Components from React, but I kind of hit a wall.
Thanks for any advise.
The data the results page receives from the server is hierarchical: query -> hit -> hsp.
hit details are not available in hsp object.
But what you want to do is quite simple. See how the generate_fasta method is called in hit.js and sidebar.js. They attach a hit_id property to the hsp objects. You can include the hit number there, either as part of hit_id or hsp_id or a separate field.
Correction: see how alignment exporter is called in hit.js, sidebar.js, etc.