#####################
updated on Sept. 10th 2015
by Saurabh Baheti
###################


Download tarball -
...........................................................
1. Unpack the source downloaded tarball.
2. cd into the expanded folder.
3. If you encountered no errors, then you are ready to run the tool
   If not, try to troubleshoot then email me: baheti dot saurabh at mayo dot edu
4. Install bowtie2 before using the tool and add the bowtie path to enviornment variable PATH
5. Download the reference genome FASTA file from the respective source based on the species you are using
6. Use the tool to get the RRBS data anlaysis.


Examples:

########
set the enviornment
#######

export PATH=<pathto bowtie>:$PATH
export PATH=<path to samtools>:$PATH

output=<where you want the data to be put according to your file system>

ref=<reference genome FASTA file>

#################
###creating the rrbs simulted reads from reference genome
######################

java -jar methyl_read_sim.jar \
	-adapter_3 AGATCGGAAGAGCGGTTCAGCAGGAATGCCGAGACCGATCTCGTATGCCGTCTTCTGCTTG \
	-adapter_5 AGATCGGAAGAGCGTCGTGTAGGGAAAGAGTGTAGATCTCGGTGGTCGCCGTATCATT \
 	-max_frag_len 300 \
	-mean_frag_len 70  \
 	-min_frag_len 40 \
 	-num_read 10000 \
 	-oprefix $output/sim \
 	-prob 0.2 \
 	-random_seed 1 \
 	-read_len 50 \
 	-ref_fa $ref \
 	-sd_frag_len 40 


################## 
###creating the bowtie2 index for the digested genome
##################

bowtie2-build $output/sim.rrbs.frag.meth.fa $output/sim.rrbs.frag.meth.fa


##################
###methylating the reads
#################

java -jar methyl_fq2bisulfite.jar \
	-end_type 1 \
	-in_fq sim_end1.fastq \
	-out_fq $output/sim_end1_meth.fastq 

##### if PAIRED END data

java -jar methyl_fq2bisulfite.jar \
        -end_type 2 \
        -in_fq sim_end2.fastq \
        -out_fq $output/sim_end2_meth.fastq


############################
####align the data uisng bowtie2
### make sure you using all the paremters mentioned below as next tool will be uisng those options.
### use these flags to align the data
--reorder          force SAM output order to match order of input reads
--no-discordant    suppress discordant alignments for paired reads
--no-dovetail      not concordant when mates extend past each other
--end-to-end       entire read must align; no clipping (on)
--very-sensitive   -D 20 -R 3 -N 0 -L 20 -i S,1,0.50
-p 		   threads (based on number of machines you have)
##############################

bowtie2 --reorder --phred64 --very-sensitive --end-to-end --dovetail --no-discordant --rdg 10000,10000 --rfg 10000,10000 -p 1 -x $output/sim.rrbs.frag.meth.fa -1 $output/sim_end1_meth.fastq -2 $output/sim_end2_meth.fastq  | samtools view -bS - > $output/sim.bam

####################
####get methylation calls
###################

java -jar methyl_caller.jar \
	-frag_fa $output/sim.rrbs.frag.fa \
 	-in_bam $output/sim.bam \
 	-in_fq1 $output/sim_end1.fastq \
 	-in_fq2 $output/sim_end2.fastq \
	-out_prefix $output/cpg

###############################################
##################
