<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Description
Step1:  Init
Step2:  Creating DR consensus seqs & loading into CLdb
Step3:  That's it! Now, the CLdb.sqlite file contains the DR consensus sequences for each CRISPR locus
Assessing DR consensus seqs
Step4:  Sequence naming is 'locus_ID'|'subtype'
Making a quick tree of DR consensus sequences
Alignment
Step5:  Tree inference
<ASSISTANT_TASK:>
Python Code:
# directory where you want the spacer blasting to be done
## CHANGE THIS!
workDir = "/home/nyoungb2/t/CLdb_Ecoli/DR_consensus/"
Explanation: Description:
This notebook goes through the creation and assessment of direct repeat (DR) consensus sequences
Before running this notebook:
run the Setup notebook
User-defined variables
End of explanation
import os
from IPython.display import FileLinks
%load_ext rpy2.ipython
if not os.path.isdir(workDir):
    os.makedirs(workDir)
# checking that CLdb is in $PATH & ~/.CLdb config file is set up
!CLdb --config-params
Explanation: Init
End of explanation
!CLdb -- loadDRConsensus
Explanation: Creating DR consensus seqs & loading into CLdb
End of explanation
!CLdb -- DRconsensus2fasta -h
# writing out the consensus sequences
!cd $workDir; \
    CLdb -- DRconsensus2fasta > DR_consensus.fna
    
# checking output    
!cd $workDir; \
    head -n 6 DR_consensus.fna
Explanation: That's it! Now, the CLdb.sqlite file contains the DR consensus sequences for each CRISPR locus
Assessing DR consensus seqs
End of explanation
!cd $workDir; \
    mafft --adjustdirection DR_consensus.fna > DR_consensus_aln.fna
    
!cd $workDir; \
    echo "#-------#"; \
    head -n 6 DR_consensus_aln.fna
Explanation: Sequence naming is 'locus_ID'|'subtype'
Making a quick tree of DR consensus sequences
Alignment
End of explanation
%%R
library(ape)
%%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')
Explanation: Tree inference
End of explanation
<END_TASK>