gfa 0.5.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/bin/gfa-mean-depth +37 -0
- data/bin/gfa-merge +34 -0
- data/bin/gfa-paths-to-fasta +29 -0
- data/lib/gfa/common.rb +13 -0
- data/lib/gfa/version.rb +1 -1
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dc98fa1d3479be3fee554dab64876d6cd42795aec08a6b60be6ccb148c57c679
|
4
|
+
data.tar.gz: 28ef77ca42b374e58c983f474d44801060dadb2df912230e431cf40ee8f1386c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1a7226dbe5813cc9e7b0cde0e756b0b41395d45e690fd3df0e6ad266f51a209d55d72fdaeaab5aaebd3fec7ce033b54bb04510903cc3eadef230bd30485f037e
|
7
|
+
data.tar.gz: 32f081a9cf35219f05cb21654011a32a1645f13cbf1d7dda320ebef0b7d893523943cd71f8c9f8a310f1021b6adfaa99b1f863d498be1bbb77bf0a5e04779efd
|
data/bin/gfa-mean-depth
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# @package MiGA
|
4
|
+
# @license Artistic-2.0
|
5
|
+
|
6
|
+
$LOAD_PATH.push File.expand_path('../../lib', __FILE__)
|
7
|
+
$LOAD_PATH.push File.expand_path('../../lib', File.realpath(__FILE__))
|
8
|
+
|
9
|
+
require 'gfa'
|
10
|
+
|
11
|
+
input, threads = ARGV
|
12
|
+
|
13
|
+
unless input
|
14
|
+
$stderr.puts <<~HELP
|
15
|
+
Calculate the average sequencing depth of all segments in the GFA
|
16
|
+
weighted by the segment lengths
|
17
|
+
|
18
|
+
gfa-mean-depth <input> [<threads>]
|
19
|
+
|
20
|
+
<input> Input GFA file to read
|
21
|
+
<threads> If passed, parallelize process with these many threads
|
22
|
+
HELP
|
23
|
+
exit(1)
|
24
|
+
end
|
25
|
+
|
26
|
+
$stderr.puts "Loading GFA: #{input}"
|
27
|
+
gfa = GFA.load_parallel(input, (threads || 1).to_i)
|
28
|
+
|
29
|
+
$stderr.puts 'Calculating average depth'
|
30
|
+
n = gfa.total_length
|
31
|
+
avg =
|
32
|
+
gfa.segments.set.map do |segment|
|
33
|
+
raise "Some segments are missing depth data" unless segment.DP
|
34
|
+
segment.DP.value * segment.length / n
|
35
|
+
end.inject(:+)
|
36
|
+
puts avg
|
37
|
+
|
data/bin/gfa-merge
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# @package MiGA
|
4
|
+
# @license Artistic-2.0
|
5
|
+
|
6
|
+
$LOAD_PATH.push File.expand_path('../../lib', __FILE__)
|
7
|
+
$LOAD_PATH.push File.expand_path('../../lib', File.realpath(__FILE__))
|
8
|
+
|
9
|
+
require 'gfa'
|
10
|
+
|
11
|
+
output = ARGV.shift
|
12
|
+
input = ARGV
|
13
|
+
|
14
|
+
if input.empty?
|
15
|
+
$stderr.puts <<~HELP
|
16
|
+
Combine several GFAs into a single GFA. Requires uniqueness of element names
|
17
|
+
|
18
|
+
gfa-merge <output> <input...>
|
19
|
+
|
20
|
+
<output> Output GFA file to be created
|
21
|
+
<input...> List of input GFA files to read
|
22
|
+
HELP
|
23
|
+
exit(1)
|
24
|
+
end
|
25
|
+
|
26
|
+
gfa = GFA.new
|
27
|
+
input.each do |i|
|
28
|
+
$stderr.puts "Merging GFA: #{i}"
|
29
|
+
gfa.merge! GFA.load(i)
|
30
|
+
end
|
31
|
+
|
32
|
+
$stderr.puts "Saving GFA: #{output}"
|
33
|
+
gfa.save(output)
|
34
|
+
|
@@ -0,0 +1,29 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# @package MiGA
|
4
|
+
# @license Artistic-2.0
|
5
|
+
|
6
|
+
$LOAD_PATH.push File.expand_path('../../lib', __FILE__)
|
7
|
+
$LOAD_PATH.push File.expand_path('../../lib', File.realpath(__FILE__))
|
8
|
+
|
9
|
+
require 'gfa'
|
10
|
+
|
11
|
+
input, output, threads = ARGV
|
12
|
+
|
13
|
+
unless output
|
14
|
+
$stderr.puts <<~HELP
|
15
|
+
Extract the sequences of the paths from a GFA to FastA file
|
16
|
+
|
17
|
+
gfa-merge <input> <output> [<threads>]
|
18
|
+
|
19
|
+
<input> Input GFA file to read
|
20
|
+
<output> Output FastA file to be created
|
21
|
+
<threads> If passed, parallelize process with these many threads
|
22
|
+
HELP
|
23
|
+
exit(1)
|
24
|
+
end
|
25
|
+
|
26
|
+
$stderr.puts "Loading GFA: #{input}"
|
27
|
+
gfa = GFA.load_parallel(input, (threads || 1).to_i)
|
28
|
+
|
29
|
+
|
data/lib/gfa/common.rb
CHANGED
@@ -67,4 +67,17 @@ class GFA
|
|
67
67
|
def total_length
|
68
68
|
segments.total_length
|
69
69
|
end
|
70
|
+
|
71
|
+
##
|
72
|
+
# Adds the entrie of +gfa+ to itself
|
73
|
+
def merge!(gfa)
|
74
|
+
records.each { |k, v| v.merge!(gfa.records[k]) }
|
75
|
+
self
|
76
|
+
end
|
77
|
+
|
78
|
+
##
|
79
|
+
# Creates a new GFA based on itself and appends all entries in +gfa+
|
80
|
+
def merge(gfa)
|
81
|
+
GFA.new(opts).merge!(self).merge!(gfa)
|
82
|
+
end
|
70
83
|
end
|
data/lib/gfa/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gfa
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Luis M. Rodriguez-R
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-10-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rgl
|
@@ -65,6 +65,9 @@ files:
|
|
65
65
|
- Rakefile
|
66
66
|
- bin/gfa-add-gaf
|
67
67
|
- bin/gfa-greedy-modules
|
68
|
+
- bin/gfa-mean-depth
|
69
|
+
- bin/gfa-merge
|
70
|
+
- bin/gfa-paths-to-fasta
|
68
71
|
- bin/gfa-subgraph
|
69
72
|
- lib/gfa.rb
|
70
73
|
- lib/gfa/common.rb
|