In [1]:
# directory where you want the spacer blasting to be done
## CHANGE THIS!
workDir = "/home/nyoungb2/t/CLdb_Ecoli/DR_consensus/"
In [2]:
import os
from IPython.display import FileLinks
%load_ext rpy2.ipython
In [3]:
if not os.path.isdir(workDir):
os.makedirs(workDir)
In [4]:
# checking that CLdb is in $PATH & ~/.CLdb config file is set up
!CLdb --config-params
In [5]:
!CLdb -- loadDRConsensus
That's it! Now, the CLdb.sqlite file contains the DR consensus sequences for each CRISPR locus
In [6]:
!CLdb -- DRconsensus2fasta -h
In [9]:
# writing out the consensus sequences
!cd $workDir; \
CLdb -- DRconsensus2fasta > DR_consensus.fna
# checking output
!cd $workDir; \
head -n 6 DR_consensus.fna
Sequence naming is 'locus_ID'|'subtype'
In [17]:
!cd $workDir; \
mafft --adjustdirection DR_consensus.fna > DR_consensus_aln.fna
!cd $workDir; \
echo "#-------#"; \
head -n 6 DR_consensus_aln.fna
In [10]:
%%R
library(ape)
In [27]:
%%R -i workDir
inFile = file.path(workDir, 'DR_consensus_aln.fna')
seqs = read.dna(inFile, format='fasta')
seqs.dist = dist.dna(seqs)
plot(hclust(seqs.dist), main='Hierarchical clustering dendrogram')
plot(nj(seqs.dist), main='Neighbor-joining tree')