wilzbach / msa

Modular BioJS compoment for a multiple sequence alignment
http://msa.biojs.net
Boost Software License 1.0
168 stars 79 forks source link

Add example of importing sequences from a string #205

Closed sbliven closed 8 years ago

sbliven commented 8 years ago

It took me quite a while to figure out how to make a MSA based on a string in javascript. You might consider adding an example of this to the documentation.

var fasta = ">seq1\n\
ACTG\n\
>seq2\n\
ACGG\n";
var m = new msa.msa(opts);
var s = m.u.file.importFile(fasta,{});
m.render();

jsbin

wilzbach commented 8 years ago

It took me quite a while to figure out how to make a MSA based on a string in javascript. You might consider adding an example of this to the documentation.

Oh I am sorry, there's even a cleaner way to do this, by using msa.io.fasta.parse(<string>) which yields a sequence object.

var fasta = ">seq1\n\
ACTG\n\
>seq2\n\
ACGG\n";

var opts = {
    el: document.getElementById("msa"),
    seqs: msa.io.fasta.parse(fasta),
    vis: {
        conserv: false,
        overviewbox: false
    }
};

var m = msa(opts);
m.render();

jsbin

I will definitely update the docs now :)

wilzbach commented 8 years ago

I will definitely update the docs now :)

-> #209

sbliven commented 8 years ago

Thanks, that's very helpful.