1
1
# Recipies
2
2
3
- ## Creating a Project
3
+ ## Creating a Julia Project
4
4
5
5
``` bash
6
- julia -e ' using Pkg; Pkg.generate("myproject")' \
7
- && cd myproject \
8
- && julia --project=. -e ' using Pkg; Pkg.add("https://github.com/ian-small/chloe.git")'
6
+ # create a Julia project in directory myproject
7
+ julia -e ' using Pkg; Pkg.generate("myproject")'
8
+ cd myproject
9
+ # add Chloe to the project
10
+ julia --project=. -e ' using Pkg; Pkg.add("https://github.com/ian-small/chloe.git")'
11
+ # get Chloe database (This can be placed anywhere you want really)
12
+ git clone https://github.com/ian-small/chloe_references
13
+ ```
14
+
15
+ ## CommandLine
16
+
17
+ Annotate a fasta file from the command line.
18
+
19
+ ``` bash
20
+ # note the '--'
21
+ julia --project=. -e ' using Chloe; chloe_main()' -- annotate NC_011032.1.fa
9
22
```
10
23
11
24
## Simple
12
25
13
- Annotate a single FASTA file
26
+ Annotate a single FASTA file.
14
27
15
28
``` julia
16
29
import Chloe
17
- import Logging
18
-
30
+ # to quieten Chloe set the logging level:
31
+ # import Logging
19
32
# Logging.disable_logging(Logging.Info) # Disable debug and info
20
33
21
- # cd && git clone https://github.com/ian-small/chloe_references
22
- db = Chloe. ReferenceDbFromDir (" ~/chloe_references" )
34
+ references = Chloe. ReferenceDbFromDir (" chloe_references" )
23
35
24
- outfile, uid = Chloe. annotate (db , " NC_011032.1.fa" )
36
+ outfile, uid = Chloe. annotate (references , " NC_011032.1.fa" )
25
37
26
38
println (outfile)
27
39
```
40
+
41
+ Write to buffer instead of to a file.
42
+
43
+ ``` julia
44
+ import Chloe
45
+ references = Chloe. ReferenceDbFromDir (" chloe_references" )
46
+ io, uid = Chloe. annotate (references, " NC_011032.1.fa" , nothing , IOBuffer ())
47
+ # show .sff content
48
+ println (String (take! (io)))
49
+ ```
50
+
51
+ Read from an already open fasta file.
52
+
53
+
54
+ ``` julia
55
+ import Chloe
56
+ references = Chloe. ReferenceDbFromDir (" chloe_references" )
57
+ outfile, uid = open (" NC_011032.1.fa" , " r" ) do io
58
+ Chloe. annotate (references, io)
59
+ end
60
+ ```
28
61
## Distributed
29
62
63
+ It's easy to annotate multiple fasta files in parallel
64
+
30
65
``` julia
31
66
using Distributed
32
67
# add workers
33
68
addprocs (2 )
34
69
35
70
@everywhere begin
36
71
import Chloe
72
+ # to quieten Chloe set the logging level:
37
73
# import Logging
38
74
# Logging.disable_logging(Logging.Info) # Disable debug and info
39
- references = Chloe. ReferenceDbFromDir (" ~/ chloe_references" )
75
+ references = Chloe. ReferenceDbFromDir (" chloe_references" )
40
76
end
41
77
42
78
fasta_directory = " fastas"
43
79
44
80
pmap = f -> l -> map (f, l)
81
+ # find all fasta files in a directory
45
82
fastas = readdir (dir) |> filter (f -> endswith (f, r" \. fa" )) |> pmap (f -> joinpath (fasta_directory, f))
46
- outputs = @distributed (vcat) for fname = fastas
47
- # note that references in on a worker process
48
- output, uid = Chloe. annotate (references, fname, nothing , fname * " .sff" )
83
+
84
+ # outputs is the list of output files
85
+ outputs = @distributed (vcat) for fasta = fastas
86
+ # note that `references` in on the worker process
87
+ output, uid = Chloe. annotate (references, fasta, nothing , fasta * " .sff" )
49
88
[output]
50
89
end
51
90
```
@@ -55,8 +94,8 @@ using Distributed
55
94
addprocs (4 )
56
95
@everywhere begin
57
96
using Chloe
58
- db = ReferenceDbFromDir (" ~/chloe_references" )
97
+ references = ReferenceDbFromDir (" ~/chloe_references" )
59
98
end
60
- r = fetch (@spawnat :any annotate (db , " NC_011032.1.fa" ))
99
+ r = fetch (@spawnat :any annotate (references , " NC_011032.1.fa" ))
61
100
println (r)
62
101
```
0 commit comments