gfa 0.5.0 → 0.6.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9eaaaf8bcac372e7d6b63d96aee94493faa51d78f5cc2b7edb525c3fbd7efaa2
4
- data.tar.gz: 950e9ffa9cd07cdea8ef5cc80b6c162bf009ff3bef5ab757dcda51c443925043
3
+ metadata.gz: cf18e4a80f49fc9c0ae4574c5c7bbc3c97fd41eaf5c7aff9fdd7991b7d562ccf
4
+ data.tar.gz: ac6999ffbbbeba45f9b81c6081ac16339ce4bb55502a77b116c77f91870af991
5
5
  SHA512:
6
- metadata.gz: 92e53b9d6c09b1814f3feda86b67dcea6192bd935e3c04dcca7b6ee9c0e7eed919c711941985313c2918f02772f3598883f037638e6e1b7cc9cf8897fec80caf
7
- data.tar.gz: 4c14ce2bd91582b7b81bc6123443bd5b0cffe8c83550fb85dc48c8da030d35dafaf393506d537c5df7550b25b87ab10003a938c407bd6210983e5f8841552317
6
+ metadata.gz: c8ae1b273166574d8520aa1f747ac0dbd08e8f31846754ca6c3fa7f0432d5f31583aa915fcebb04a220e90fe14aeeb4f06dec2a5c23527571c9bb337de0ef9a5
7
+ data.tar.gz: f5fce0959cace1fe961d92fab2946bf8b67571ee6ceef3cd6e7047d8c46f0855b28e6b703ffbfe327ef8d09e1174b94ee98423ae36bb858bab76615849e0bd94
data/bin/gfa-add-gaf CHANGED
@@ -18,11 +18,13 @@ unless degree
18
18
  <input-gaf> Input GAF file to read
19
19
  <output> Output GFA file to write
20
20
  <degree> Maximum degree of separation between the segment set in the GAF
21
- and any other included segments. If 0, only segments are
22
- included. If 1, only the target segments, records linking to
23
- them, and segments linked by those records. Any integer > 1
24
- includes additional expansion rounds for those linked segments.
25
- Use -1 to include the complete original GAF without subsetting.
21
+ and any other segments included in the output GFA.
22
+ - -1: include the complete original GAF without subsetting.
23
+ - 0: only segments in the GAF are included.
24
+ - 1: only the target segments in the GAF, records linking to
25
+ them, and segments linked by those records are included.
26
+ - Any integer > 1: include additional expansion rounds for
27
+ those linked segments.
26
28
  <pref> A prefix to name all recorded paths
27
29
  By default: Based on the GAF file name
28
30
  <threads> If passed, parallelize process with these many threads
@@ -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/graph.rb CHANGED
@@ -146,7 +146,7 @@ class GFA
146
146
 
147
147
  def internally_linking_records(segments, edges)
148
148
  $stderr.puts '- Gathering internally linking records'
149
- segments = Hash[segments.set.map { |i| [i.name.value, true]}]
149
+ segments = Hash[segments.map { |i| [i.name.value, true]}]
150
150
  edges.select { |record| record.segment_names_a.all? { |s| segments[s] } }
151
151
  end
152
152
 
data/lib/gfa/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  class GFA
2
- VERSION = '0.5.0'
2
+ VERSION = '0.6.1'
3
3
  VERSION_ARRAY = VERSION.split(/\./).map { |x| x.to_i } # :nodoc:
4
4
  VERSION_MAJOR = VERSION_ARRAY[0] # :nodoc:
5
5
  VERSION_MINOR = VERSION_ARRAY[1] # :nodoc:
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.5.0
4
+ version: 0.6.1
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-03-26 00:00:00.000000000 Z
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