new file: alignpe.py
[GalaxyCodeBases.git] / BGI / SOAPdenovo2 / README
blobccc07a48c959043f9d697fe7d316dbc8016bb621
2 Manual of SOAPdenovo-V2.04
4 Ruibang Luo, 2012-7-10
5 Zhenyu Li, 2012-7-10
7 **********************************************************
8 Introduction
10 SOAPdenovo is a novel short-read assembly method that can build a de novo draft assembly for the human-sized genomes. The program is specially designed to assemble Illumina GA short reads. It creates new opportunities for building reference sequences and carrying out accurate analyses of unexplored genomes in a cost effective way.
12 ************
13 System Requirement
15 SOAPdenovo aims for large plant and animal genomes, although it also works well on bacteria and fungi genomes.  It runs on 64-bit Linux system with a minimum of 5G physical memory. For big genomes like human, about 150 GB memory would be required.
17 ************
18 Update Log
20 1) 63mer and 127mer versions were merged.
22 2) A new module named "sparse-pregraph" was added which can reduce considerable computational comsumption.
24 3) "Multi-kmer" method was introduced in "contig" step which allows the utilization of the advantages of small and large kmer.
26 4) Algorithm of scaffolding was improved to get longer and more accuracy scaffolds.
28 5) AIO (Asynchronous Input/Output) was introduced to boost the performance of reading files.
30 6) Information for visualization purpose was available after scaffolding.
32 7) Several bugs fixed.
34 ************
35 Installation
36 1. You can download the pre-compiled binary according to your platform, unpack using "tar -zxf  ${destination folder} download.tgz" and execute directly.
37 2. Or download the source code, unpack to ${destination folder} with the method above, and compile by using GNU make with command "make" at ${destination folder}/SOAPdenovo-V2.04. Then install executable to ${destination folder}/SOAPdenovo-V2.04/bin using "make install"
39 ************
40 How to use it
42 1. Configuration file
44 For big genome projects with deep sequencing, the data is usually organized as multiple read sequence files generated from multiple libraries. The configuration file tells the assembler where to find these files and the relevant information. "example.config" is an example of such a file.
46 The configuration file has a section for global information, and then multiple library sections. Right now only "max_rd_len" is included in the global information section. Any read longer than max_rd_len will be cut to this length. 
48 The library information and the information of sequencing data generated from the library should be organized in the corresponding library section. Each library section starts with tag [LIB] and includes the following items:
49 1) avg_ins
50    This value indicates the average insert size of this library or the peak value position in the insert size distribution figure.
51 2) reverse_seq
52    This option takes value 0 or 1. It tells the assembler if the read sequences need to be complementarily reversed. 
53 Illumima GA produces two types of paired-end libraries: a) forward-reverse, generated from fragmented DNA ends with typical insert size less than 500 bp; b) reverse-forward, generated from circularizing libraries with typical insert size greater than 2 Kb. The parameter "reverse_seq" should be set to indicate this: 0, forward-reverse; 1, reverse-forward.
54 3) asm_flags
55    This indicator decides in which part(s) the reads are used. It takes value 1(only contig assembly), 2 (only scaffold assembly), 3(both contig and scaffold assembly), or 4 (only gap closure).
56 4) rd_len_cutof
57    The assembler will cut the reads from the current library to this length.
58 5) rank
59    It takes integer values and decides in which order the reads are used for scaffold assembly. Libraries with the same "rank" are used at the same time during scaffold assembly. 
60 6) pair_num_cutoff
61    This parameter is the cutoff value of pair number for a reliable connection between two contigs or pre-scaffolds. The minimum number for paired-end reads and mate-pair reads is 3 and 5 respectively.
62 7) map_len
63    This takes effect in the "map" step and is the minimun alignment length between a read and a contig required for a reliable read location. The minimum length for paired-end reads and mate-pair reads is 32 and 35 respectively.
65 The assembler accepts read file in three kinds of formats: FASTA, FASTQ and BAM. Mate-pair relationship could be indicated in two ways: two sequence files with reads in the same order belonging to a pair, or two adjacent reads in a single file (FASTA only) belonging to a pair. If a read in bam file fails platform/vendor quality checks(the flag field 0x0200 is set), itself and it's paired read would be ignored.
67 In the configuration file single end files are indicated by "f=/path/filename" or "q=/pah/filename" for fasta or fastq formats separately. Paired reads in two fasta sequence files are indicated by "f1=" and "f2=". While paired reads in two fastq sequences files are indicated by "q1=" and "q2=". Paired reads in a single fasta sequence file is indicated by "p=" item. Reads in bam sequence files is indicated by "b=".
69 All the above items in each library section are optional. The assembler assigns default values for most of them. If you are not sure how to set a parameter, you can remove it from your configuration file.
71 2. Get it started
72 Once the configuration file is available, a typical way to run the assembler is:
73 ${bin} all -s config_file -K 63 -R -o graph_prefix 1>ass.log 2>ass.err
75 User can also choose to run the assembly process step by step as:
76 step1:
77 ${bin} pregraph -s config_file -K 63 -R -o graph_prefix 1>pregraph.log 2>pregraph.err  
79 ${bin} sparse_pregraph -s config_file -K 63 -z 5000000000 -R -o graph_prefix 1>pregraph.log 2>pregraph.err 
81 step2:
82 ${bin} contig -g graph_prefix -R 1>contig.log 2>contig.err
84 step3:
85 ${bin} map -s config_file -g graph_prefix 1>map.log 2>map.err
87 step4:
88 ${bin} scaff -g graph_prefix -F 1>scaff.log 2>scaff.err
90 3.Options
92 3.1 Options for all (pregraph-contig-map-scaff)
93   -s <string>    configFile: the config file of solexa reads
94   -o <string>    outputGraph: prefix of output graph file name
95   -K <int>       kmer(min 13, max 63/127): kmer size, [23]
96   -p <int>       n_cpu: number of cpu for use, [8]
97   -a <int>       initMemoryAssumption: memory assumption initialized to avoid further reallocation, unit G, [0]
98   -d <int>       KmerFreqCutoff: kmers with frequency no larger than KmerFreqCutoff will be deleted, [0]
99   -R (optional)  resolve repeats by reads, [NO]
100   -D <int>       EdgeCovCutoff: edges with coverage no larger than EdgeCovCutoff will be deleted, [1]
101   -M <int>       mergeLevel(min 0, max 3): the strength of merging similar sequences during contiging, [1]
102   -m <int>       max k when using multi kmer
103   -e <int>       weight to filter arc when linearize two edges(default 0)
104   -r (optional)  keep available read(*.read)
105   -E (optional)  merge clean bubble before iterate
106   -f (optional)  output gap related reads in map step for using SRkgf to fill gap, [NO]
107   -k <int>       kmer_R2C(min 13, max 63): kmer size used for mapping read to contig, [K]
108   -F (optional)  fill gaps in scaffold, [NO]
109   -u (optional)  un-mask contigs with high/low coverage before scaffolding, [mask]
110   -w (optional)  keep contigs weakly connected to other contigs in scaffold, [NO]
111   -G <int>       gapLenDiff: allowed length difference between estimated and filled gap, [50]
112   -L <int>       minContigLen: shortest contig for scaffolding, [K+2]
113   -c <float>     minContigCvg: minimum contig coverage (c*avgCvg), contigs shorter than 100bp with coverage smaller than c*avgCvg will be masked before scaffolding unless -u is set, [0.1]
114   -C <float>     maxContigCvg: maximum contig coverage (C*avgCvg), contigs with coverage larger than C*avgCvg or contigs shorter than 100bp with coverage larger than 0.8*C*avgCvg will be masked before scaffolding unless -u is set, [2]
115   -b <float>     insertSizeUpperBound: (b*avg_ins) will be used as upper bound of insert size for large insert size ( > 1000) when handling pair-end connections between contigs if b is set to larger than 1, [1.5]
116   -B <float>     bubbleCoverage: remove contig with lower cvoerage in bubble structure if both contigs' coverage are smaller than bubbleCoverage*avgCvg, [0.6]
117   -N <int>       genomeSize: genome size for statistics, [0]
118   -V (optional)  output visualization information of assembly, [NO]
120 3.2 Options for sparse_pregraph
121   Usage: ./SOAPdenovo2 sparse_pregraph -s configFile -K kmer -z genomeSize -o outputGraph [-g maxKmerEdgeLength -d kmerFreqCutoff -e kmerEdgeFreqCutoff -R -r runMode -p n_cpu]
122   -s <string>     configFile: the config file of solexa reads
123   -K <int>        kmer(min 13, max 63/127): kmer size, [23]
124   -g <int>        maxKmerEdgeLength(min 1, max 25): number of skipped intermediate kmers, [15]
125   -z <int>        genomeSize(mandatory): estimated genome size
126   -d <int>        kmerFreqCutoff: delete kmers with frequency no larger than,[1]
127   -e <int>        kmerEdgeFreqCutoff: delete kmers' related edge with frequency no larger than [1]
128   -R (optional)   output extra information for resolving repeats in contig step, [NO]
129   -r <int>        runMode: 0 build graph & build edge and preArc, 1 load graph by prefix & build edge and preArc, 2 build graph only, 3 build edges only, 4 build preArcs only [0]
130   -p <int>        n_cpu: number of cpu for use,[8]
131   -o <int>        outputGraph: prefix of output graph file name
133 4. Output files
135 4.1 These files are output as assembly results:
136 a. *.contig     
137   contig sequences without using mate pair information.
138 b. *.scafSeq    
139   scaffold sequences (final contig sequences can be extracted by breaking down scaffold sequences at gap regions).
141 4.2 There are some other files that provide useful information for advanced users, which are listed in Appendix B.
143 5. FAQ
145 5.1 How to set K-mer size?
147 The program accepts odd numbers between 13 and 31. Larger K-mers would have higher rate of uniqueness in the genome and would make the graph simpler, but it requires deep sequencing depth and longer read length to guarantee the overlap at any genomic location.
149 The sparse pregraph module usually needs 2-10bp smaller kmer length to achieve the same performance as the original pregraph module.
151 5.2 How to set genome size(-z) for sparse pregraph module?
153 The -z parameter for sparse pregraph should be set a litter larger than the real genome size, it is used to allocate memory.
155 5.3 How to set library rank?
157 SOAPdenovo will use the pair-end libraries with insert size from smaller to larger to construct scaffolds. Libraries with the same rank would be used at the same time. For example, in a dataset of a human genome, we set five ranks for five libraries with insert size 200-bp, 500-bp, 2-Kb, 5-Kb and 10-Kb, separately. It is desired that the pairs in each rank provide adequate physical coverage of the genome.
159 ************
160 APPENDIX A: an example.config 
162 #maximal read length
163 max_rd_len=100
164 [LIB]
165 #average insert size
166 avg_ins=200
167 #if sequence needs to be reversed 
168 reverse_seq=0
169 #in which part(s) the reads are used
170 asm_flags=3
171 #use only first 100 bps of each read
172 rd_len_cutoff=100
173 #in which order the reads are used while scaffolding
174 rank=1
175 # cutoff of pair number for a reliable connection (at least 3 for short insert size)
176 pair_num_cutoff=3
177 #minimum aligned length to contigs for a reliable read location (at least 32 for short insert size)
178 map_len=32
179 #a pair of fastq file, read 1 file should always be followed by read 2 file
180 q1=/path/**LIBNAMEA**/fastq1_read_1.fq
181 q2=/path/**LIBNAMEA**/fastq1_read_2.fq
182 #another pair of fastq file, read 1 file should always be followed by read 2 file
183 q1=/path/**LIBNAMEA**/fastq2_read_1.fq
184 q2=/path/**LIBNAMEA**/fastq2_read_2.fq
185 #a pair of fasta file, read 1 file should always be followed by read 2 file
186 f1=/path/**LIBNAMEA**/fasta1_read_1.fa
187 f2=/path/**LIBNAMEA**/fasta1_read_2.fa
188 #another pair of fasta file, read 1 file should always be followed by read 2 file
189 f1=/path/**LIBNAMEA**/fasta2_read_1.fa
190 f2=/path/**LIBNAMEA**/fasta2_read_2.fa
191 #fastq file for single reads
192 q=/path/**LIBNAMEA**/fastq1_read_single.fq
193 #another fastq file for single reads
194 q=/path/**LIBNAMEA**/fastq2_read_single.fq
195 #fasta file for single reads
196 f=/path/**LIBNAMEA**/fasta1_read_single.fa
197 #another fasta file for single reads
198 f=/path/**LIBNAMEA**/fasta2_read_single.fa
199 #a single fasta file for paired reads
200 p=/path/**LIBNAMEA**/pairs1_in_one_file.fa
201 #another single fasta file for paired reads
202 p=/path/**LIBNAMEA**/pairs2_in_one_file.fa
203 #bam file for single or paired reads, reads 1 in paired reads file should always be followed by reads 2
204 #       NOTE: If a read in bam file fails platform/vendor quality checks(the flag field 0x0200 is set), itself and it's paired read would be ignored.
205 b=/path/**LIBNAMEA**/reads1_in_file.bam
206 #another bam file for single or paired reads
207 b=/path/**LIBNAMEA**/reads2_in_file.bam
208 [LIB]
209 avg_ins=2000
210 reverse_seq=1
211 asm_flags=2
212 rank=2
213 # cutoff of pair number for a reliable connection (at least 5 for large insert size)
214 pair_num_cutoff=5
215 #minimum aligned length to contigs for a reliable read location (at least 35 for large insert size)
216 map_len=35
217 q1=/path/**LIBNAMEB**/fastq_read_1.fq
218 q2=/path/**LIBNAMEB**/fastq_read_2.fq
219 f1=/path/**LIBNAMEA**/fasta_read_1.fa
220 f2=/path/**LIBNAMEA**/fasta_read_2.fa
221 p=/path/**LIBNAMEA**/pairs_in_one_file.fa
222 b=/path/**LIBNAMEA**/reads_in_file.bam
224 ************
225 Appendix B: output files
227 1. Output files from the command "pregraph"
228    a. *.kmerFreq
229       Each row shows the number of Kmers with a frequency equals the row number. Note that those peaks of frequencies which are the integral multiple of 63 are due to the data structure.
230    b. *.edge 
231       Each record gives the information of an edge in the pre-graph: length, Kmers on both ends, average kmer coverage, whether it's reverse-complementarily identical and the sequence.
232    c. *.markOnEdge & *.path
233       These two files are for using reads to solve small repeats.
234    e. *.preArc
235       Connections between edges which are established by the read paths.
236    f. *.vertex
237       Kmers at the ends of edges.
238    g. *.preGraphBasic
239       Some basic information about the pre-graph: number of vertex, K value, number of edges, maximum read length etc.
241 2. Output files from the command "contig"
242    a. *.contig
243       Contig information: corresponding edge index, length, kmer coverage, whether it's tip and the sequence. Either a contig or its reverse complementry counterpart is included. Each reverse complementary contig index is indicated in the *.ContigIndex file.
244    b. *.Arc
245       Arcs coming out of each edge and their corresponding coverage by reads 
246    c. *.updated.edge
247       Some information for each edge in graph: length, Kmers at both ends, index difference between the reverse-complementary edge and this one.
248    d. *.ContigIndex
249       Each record gives information about each contig in the *.contig: it's edge index, length, the index difference between its reverse-complementary counterpart and itself.
251 3. Output files from the command "map"
252    a. *.peGrads
253       Information for each clone library: insert-size, read index upper bound, rank and pair number cutoff for a reliable link. This file can be revised manually for scaffolding tuning. 
254    b. *.readOnContig
255       Reads' locations on contigs. Here contigs are referred by their edge index. Howerver about half of them are not listed in the *.contig file for their reverse-complementary counterparts are included already.
256    c. *.readInGap
257       This file includes reads that could be located in gaps between contigs. This information will be used to close gaps in scaffolds if "-F" is set. 
259 4. Output files from the command "scaff"
260    a. *.newContigIndex
261       Contigs are sorted according their length before scaffolding. Their new index are listed in this file.  This is useful if one wants to corresponds contigs in *.contig with those in *.links.
262    b. *.links
263       Links between contigs which are established by read pairs. New index are used.
264    c. *.scaf_gap
265       Contigs in gaps found by contig graph outputted by the contiging procedure. Here new index are used.
266    d. *.scaf
267       Contigs for each scaffold: contig index (concordant to index in *.contig),  approximate start position on scaffold, orientation, contig length, and its links to others contigs.
268    e. *.gapSeq
269       Gap sequences between contigs.
270    f. *.scafSeq
271       Sequences of each scaffolds.
272    g. *.contigPosInscaff
273       Contigs' positions in each scaffold.
274    h. *.bubbleInScaff
275       Contigs that form bubble structures in scaffolds. Every two contigs form a bubble and the contig with higher coverage will be kept in scaffold.
276    i. *.scafStatistics
277       Statistic information of final scaffold and contig.