changed 6 years ago
Linked with GitHub

スクリプト -IGV起動-

## conda install -c bioconda igvtools
## conda install -c bioconda igv
## conda install -c bioconda samtools
## http://kazumaxneo.hatenablog.com/entry/2017/07/05/132019
import os
import re

species = 'hg38'

annotation_file = species+'.gtf'
annotation = os.path.join('/Users/user/ws/ref/annotation',annotation_file)

genome_dir = '/Users/user/ws/ref/genome/'
genomeFastaFile = os.path.join(genome_dir,species+'.fa')

root_dir = '/Users/user/Downloads/test_igv/output'
igv_dir = os.path.join(root_dir,'igv_dir')

bed_file = 'your_bedfile_name'
bedFile = os.path.join(igv_dir,bed_file+'.bed')


cmd = 'sed -e "s/\$/.Aligned.out.sorted.bam/" -e "s/^/\/Users\/user\/Downloads\/test_igv\/output\/igv_dir\//" %s/SRR_Acc_List.txt > %s/bamSortFile_List.txt ' % (root_dir,igv_dir)
os.system(cmd)

file = open(os.path.join(igv_dir,'bamSortFile_List.txt'),'r')
samplename = file.read().split()
filename = ' '.join(samplename)
print(filename)  



cmd = 'igv -g %s %s %s %s' % (genomeFastaFile,annotation,bedFile,filename[0:])
print(cmd)
os.system(cmd)

# An index file for /Users/petadimensionlab/ws/ref/annotation/saimiri_ensembl.gtf could not be located. An index is recommended to view files of this size.   Click "Go" to create one now or "Cancel to proceed without an index.
# > click "Go"

# F iles must be sorted by start position prior to indexing. Input file is not sorted by start position. We saw a record with a start of JH378105:25250124 after a record with a start of JH378105:25250172, for input source: /Users/petadimensionlab/ws/ref/annotation/saimiri_ensembl.gtf  Note: igvtools can be used to sort the file, select "File > Run igvtools...".
# > click "OK"


memo:
下記コマンドに関していい方法が思い浮かびませんでした・・・
→bamファイル(sort、index後の)のディレクトリ名のリストファイルを作成するコマンドです。

cmd = 'sed -e "s/$/.Aligned.out.sorted.bam/" -e "s/^//Users/user/Downloads/test_igv/output/igv_dir//" %s/SRR_Acc_List.txt > %s/bamSortFile_List.txt ' % (root_dir,igv_dir)
os.system(cmd)

memo(重要):
こちらのコマンドはbamファイル・genomeファイル・bamファイルを指定し、IGVを起動するだけのスクリプトです。
イメージの保存は手でポチポチしないといけません!!!

Select a repo