set up a BAM file

Jbrowse:diagnostic message object response error

这种错误应该就是bam文件没有排序,或者没有建立索引。

貌似samtools sort 输出文件不能和输入文件一样,不然就没排序?这导致了后面的麻烦

2019-3-5 23:45:23:排完序之后会有输出 xx merge

受了下面内容的影响,以为是web 服务器问题

Apache Configuration Note

If you are using the Apache web server, please be aware that the module mime_magic can cause BAM files to be served incorrectly. Usually, the error in the web developer console will be something like “Not a BAM file”. Some packaged versions of Apache, particularly on Red Hat or CentOS-based systems, are configured with this module turned on by default. We recommend you deactivate this Apache module for the server or directory used to serve JBrowse files. If you do not want to deactivate this module for the entire server, try adding this line to your HTTPD config or .htaccess file:

1
AddType application/octet-stream .bam .bami .bai
1
2
3
4
5
6
# 停止、开启服务,
systemctl stop nginx.service
systemctl start httpd.service
netstat -ntpl

/usr/bin/perl ../bin/add-bam-track.pl --label jhhbam --bam_url jhh.bam --in trackList.json

http://10.164.6.4/JBrowse-1.16.3

正确的操作

How do I set up a BAM file?有bam、bigwig的perl脚本生成json格式的配置文件

When you set up a BAM file in jbrowse, the best way to do it is as follows

  1. Put the BAM file and the BAM index (.bai) in your data directory (e.g. you downloaded jbrowse, and your did prepare-refseqs.pl, which created a data subfolder. Put your BAM file in there)
  2. Then use add-bam-track.pl like this: add-bam-track.pl –label mybam –bam_url mybam.bam –in data/trackList.json
  3. This will only create a simple section of configuration in your data directory’s trackList.json for the BAM file that will look like
1
2
3
4
5
6
7
{
"storeClass" : "JBrowse/Store/SeqFeature/BAM",
"urlTemplate" : "mybam.bam",
"label" : "mybam",
"type" : "JBrowse/View/Track/Alignments2",
"key" : "mybam"
}

This basically just instructs JBrowse to fetch “mybam.bam” using the class that understands BAM data, “JBrowse/Store/SeqFeature/BAM”, and display it with the “Alignments2” tracktype. If this does not work please post to github or gmod-ajax@lists.sourceforge.net

Other notes

  • Don’t use bam-to-json.pl, it is old and converting your probably humongous next-gen-sequencing BAM into text json is unwieldy
  • Your bam index should just be named the same as your BAM with .bai on the end
  • The add-bam-track.pl does NOT copy the bam to your data directory for you, you put it there yourself, and specify the –bam_url appropriately
  • baiUrlTemplate is unnecessary if your bai file is just your bam file with .bai added onto the end, in that case it is found automatically

排序

samtools使用

1
2
3
samtools view KL_3d_clean_filter.xRNAs.bam | less
samtools sort KL_3d_clean_filter.xRNAs.bam -o KL_3d_clean_filter.xRNAs.sorted.bam
samtools index KL_3d_clean_filter.xRNAs.sorted.bam

bam生成配置文件

1
2
# 对样品生成 json 文件
/usr/bin/perl ../bin/add-bam-track.pl --label mybam --bam_url HB-12-2_dedup.bam --in trackList.json
1
2
3
4
5
6
7
# 查看帮助,有各项参数的意思
/usr/bin/perl bin/prepare-refseqs.pl --help

# 添加key,即track显示的名称
/usr/bin/perl bin/prepare-refseqs.pl --fasta /home/qi/JHH/siRNA/Cclementina_182_v1.fa --out Ccle --key Ccle.fasta

/usr/bin/perl bin/flatfile-to-json.pl --gff /home/qi/JHH/siRNA/Cclementina_v1.0_gene_no_Cc_182.gff3 --trackType CanvasFeatures --trackLabel Ccle.gff3 --out Ccle

发现了 Cclementina Jbrowse

download fasta

–out
Data directory to process. Default ‘data/‘.

1
2
3
# 建立索引,搜索
/usr/bin/perl bin/generate-names.pl --help
/usr/bin/perl bin/generate-names.pl --out Ccle

http://10.164.6.4/index.html?data=Ccle

1
2
# 生成bam的配置文件。配置文件中的路径只能写相对路径。要把文件移到相应的文件夹下
for i in *.sorted.bam;do t=`echo $i | cut -d _ -f 1,2`;/usr/bin/perl ../bin/add-bam-track.pl --label $t --bam_url $i --in trackList.json; done

wig to bigwig

1
conda install -c bioconda ucsc-wigtobigwig

现在我用conda安装软件,总是会碰到perssion denied的问题。明天再搞了。

(base) [qi@localhost Ccle]$ ls ../bin
add-bam-track.pl add-json.pl biodb-to-json.pl draw-basepair-track.pl generate-names.pl json2conf.pl new-plugin.pl remove-track.pl
add-bw-track.pl add-track-json.pl cpanm flatfile-to-json.pl jbdoc maker2jbrowse prepare-refseqs.pl ucsc-to-json.pl