Skip to content

Instantly share code, notes, and snippets.

@zhoujj2013
Last active August 29, 2015 14:04
Show Gist options
  • Save zhoujj2013/5e2c1f861fbe904e7de5 to your computer and use it in GitHub Desktop.
Save zhoujj2013/5e2c1f861fbe904e7de5 to your computer and use it in GitHub Desktop.
import gff3 file to jbrowser by chr
#!/usr/bin/perl -w
use strict;
use Data::Dumper;
## Written by [email protected]
# import gff3 file to jbrowser by chr
# default jbrowser installation diretory is /var/www/jbrowser/
my ($gff3_f,$outdir) = @ARGV;
my %chr;
open IN,"$gff3_f" || die $!;
while(<IN>){
chomp;
next if(/^#/);
my @t = split /\t/;
$chr{$t[0]} = 1;
}
close IN;
my @chr_gff3;
mkdir "./chr_gff3" if(! -e "./chr_gff3");
open SH,">","import_gff3.sh" || die $!;
foreach my $c (keys %chr){
open OUT,">","./chr_gff3/$c.gff3" || die $!;
print SH "perl /var/www/jbrowser/bin/flatfile-to-json.pl --out $outdir --gff ./chr_gff3/$c.gff3 --type mRNA --autocomplete all --trackLabel EnsemblTrans --key 'EnsemblTrans' --getSubfeatures --className transcript --subfeatureClasses '{\"CDS\": \"transcript-CDS\"}' --arrowheadClass arrowhead --urltemplate \"http://asia.ensembl.org/Homo_sapiens/Transcript/Summary?t={id}&db=core\" --maxLookback 2000\n";
open IN,"$gff3_f" ||die $!;
my $conti = "";
while(<IN>){
chomp;
if(/^#/ && $conti eq ""){
print OUT "$_\n";
$conti = "####";
}
my @t = split /\t/;
my $id = $t[0];
if($t[0] eq $c){
print OUT "$_\n";
$conti = "";
}
}
close OUT;
}
close SH;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment