This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Draw Gene Models From Gff3 File

I have the following input GFF3 format and I want to pars it in javascript code since I did not find available tools to draw the gene models from gff file. I found many differences in the gff3 files.. What is the important fields to extract in order to draw the gene models.

I want to extract these field in order to give it to Scribl to draw the gene ..

I want the output to be like this genemodele

Here is the file : GFF

and this GFF

gene model visualization

"I have the following input GFF3 format ": where is it ?

I put the link .. but my question is based on the differences that I found.

Second link is not pointing to a GFF file. What differences are you seeing?

the number of the column is confusing some of the file they have 8 column while the other is less

1 answer

Here's a jsbin that seems to work with both of your sample files (although I haven't checked very closely).

http://jsbin.com/cuy/1/edit?js,output

The parsing and drawing code is here

var canvas = document.getElementById('canvas');      
// Create Chart
chart1 = new Scribl(canvas, 770);
chart1.laneSizes = 18;

// grab gff data
var records = $("textarea").html().split('\n');

for (var i=0; i < records.length; i++) {
 // ignore comments
 if (records[i][0] == '#') continue;
 // parse gff fields
 var fields = records[i].split("\t");
 var seqid  = fields[0],
     source = fields[1],
     type   = fields[2],
     start  = parseInt(fields[3]),
     end    = parseInt(fields[4]),
     score  = fields[5],
     strand = fields[6],
     phase  = fields[7],
     attr   = fields[8];

 // add gene to chart with desired attributes
 var gene = chart1.addGene(start, end-start, strand);
 gene.name = type;
}

// Draw Chart
chart1.draw();

thanks very much I wrote something similar and this makes me assure that I am correct.

Log in to answer this question.