lsa 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: aeb489df0e1e3be796a50a6ed5f44267da76fcdc
4
+ data.tar.gz: 03a46fe4c0aee315d155a076026655d42e91f434
5
+ SHA512:
6
+ metadata.gz: 74f92994363b2f3232f22caf4c951970238ce062b40a0044d4ec946fbe51a5c6190c3904678c3d1f2c4f6866c972fde3afd2debd81a15076840a53cd9ff0ebe3
7
+ data.tar.gz: 18e4792725af47610fcb0f443ca22389ebea7c6b4414c580b41ca5854094074134ed80efca572e9a65e57caf5465fc8b5d189e6339d021696f41a0f1359ad9b3
@@ -0,0 +1,12 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+
11
+ # rspec failure tracking
12
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
@@ -0,0 +1 @@
1
+ lsa
@@ -0,0 +1 @@
1
+ ruby-2.4.1
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.4.1
5
+ before_install: gem install bundler -v 1.15.1
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at moorer@udel.edu. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in lsa.gemspec
4
+ gemspec
@@ -0,0 +1,70 @@
1
+ # A sample Guardfile
2
+ # More info at https://github.com/guard/guard#readme
3
+
4
+ ## Uncomment and set this to only include directories you want to watch
5
+ # directories %w(app lib config test spec features) \
6
+ # .select{|d| Dir.exists?(d) ? d : UI.warning("Directory #{d} does not exist")}
7
+
8
+ ## Note: if you are using the `directories` clause above and you are not
9
+ ## watching the project directory ('.'), then you will want to move
10
+ ## the Guardfile to a watched dir and symlink it back, e.g.
11
+ #
12
+ # $ mkdir config
13
+ # $ mv Guardfile config/
14
+ # $ ln -s config/Guardfile .
15
+ #
16
+ # and, you'll have to watch "config/Guardfile" instead of "Guardfile"
17
+
18
+ # Note: The cmd option is now required due to the increasing number of ways
19
+ # rspec may be run, below are examples of the most common uses.
20
+ # * bundler: 'bundle exec rspec'
21
+ # * bundler binstubs: 'bin/rspec'
22
+ # * spring: 'bin/rspec' (This will use spring if running and you have
23
+ # installed the spring binstubs per the docs)
24
+ # * zeus: 'zeus rspec' (requires the server to be started separately)
25
+ # * 'just' rspec: 'rspec'
26
+
27
+ guard :rspec, cmd: "bundle exec rspec" do
28
+ require "guard/rspec/dsl"
29
+ dsl = Guard::RSpec::Dsl.new(self)
30
+
31
+ # Feel free to open issues for suggestions and improvements
32
+
33
+ # RSpec files
34
+ rspec = dsl.rspec
35
+ watch(rspec.spec_helper) { rspec.spec_dir }
36
+ watch(rspec.spec_support) { rspec.spec_dir }
37
+ watch(rspec.spec_files)
38
+
39
+ # Ruby files
40
+ ruby = dsl.ruby
41
+ dsl.watch_spec_files_for(ruby.lib_files)
42
+
43
+ # Rails files
44
+ rails = dsl.rails(view_extensions: %w(erb haml slim))
45
+ dsl.watch_spec_files_for(rails.app_files)
46
+ dsl.watch_spec_files_for(rails.views)
47
+
48
+ watch(rails.controllers) do |m|
49
+ [
50
+ rspec.spec.call("routing/#{m[1]}_routing"),
51
+ rspec.spec.call("controllers/#{m[1]}_controller"),
52
+ rspec.spec.call("acceptance/#{m[1]}")
53
+ ]
54
+ end
55
+
56
+ # Rails config changes
57
+ watch(rails.spec_helper) { rspec.spec_dir }
58
+ watch(rails.routes) { "#{rspec.spec_dir}/routing" }
59
+ watch(rails.app_controller) { "#{rspec.spec_dir}/controllers" }
60
+
61
+ # Capybara features specs
62
+ watch(rails.view_dirs) { |m| rspec.spec.call("features/#{m[1]}") }
63
+ watch(rails.layouts) { |m| rspec.spec.call("features/#{m[1]}") }
64
+
65
+ # Turnip features and steps
66
+ watch(%r{^spec/acceptance/(.+)\.feature$})
67
+ watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) do |m|
68
+ Dir[File.join("**/#{m[1]}.feature")][0] || "spec/acceptance"
69
+ end
70
+ end
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2017 Ryan Moore
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,33 @@
1
+ # Lsa
2
+
3
+ Library code for [LSA for (Meta)Genomes](https://github.com/mooreryan/lsa_for_genomes)
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'lsa'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install lsa
20
+
21
+ ## Development
22
+
23
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
24
+
25
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
26
+
27
+ ## Contributing
28
+
29
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/lsa. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
30
+
31
+ ## Code of Conduct
32
+
33
+ Everyone interacting in the Lsa project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/lsa/blob/master/CODE_OF_CONDUCT.md).
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "lsa"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,90 @@
1
+ require "lsa/version"
2
+
3
+ require "abort_if"
4
+
5
+ include AbortIf
6
+
7
+
8
+
9
+
10
+ module Lsa
11
+
12
+ def clean_str str
13
+ str.strip.gsub(/[^\p{Alnum}_]+/, "_").gsub(/_+/, "_")
14
+ end
15
+
16
+
17
+ def parse_mapping_file mapping_fname, mmseqs_final_outf
18
+ data_labels = []
19
+ label2outf = {}
20
+ doc2new_doc = {}
21
+ File.open(mapping_fname, "rt").each_line.with_index do |line, idx|
22
+ if idx.zero?
23
+ curren_label, *data_labels = line.chomp.split("\t").map do |str|
24
+ clean_str str
25
+ end
26
+
27
+ abort_unless data_labels.uniq.count == data_labels.count,
28
+ "The data labels are not unique in #{mapping_fname}"
29
+
30
+ data_labels.each do |label|
31
+ new_outfname =
32
+ File.join "#{mmseqs_final_outf}.metadata_#{label}.txt"
33
+
34
+ label2outf[label] = File.open new_outfname, "w"
35
+ end
36
+ else
37
+ file_name, *data = line.chomp.split("\t").map do |str|
38
+ clean_str str
39
+ end
40
+
41
+ abort_unless data_labels.length == data.length,
42
+ "Number of columns doesn't match for line " +
43
+ "#{idx + 1}"
44
+
45
+ abort_if doc2new_doc.has_key?(file_name),
46
+ "File #{file_name} is repeated in #{mapping_fname}"
47
+
48
+ doc2new_doc[file_name] = {}
49
+ data_labels.each_with_index do |label, idx|
50
+ doc2new_doc[file_name][label] = data[idx]
51
+ end
52
+ end
53
+ end
54
+
55
+ [label2outf, doc2new_doc]
56
+ end
57
+
58
+ def make_new_cluster_files mmseqs_final_outf, label2outf, doc2new_doc
59
+ File.open(mmseqs_final_outf).each_line do |line|
60
+ centroid, member = line.chomp.split "\t"
61
+
62
+ centroid_doc, centroid_seq = centroid.split "~"
63
+ member_doc, member_seq = member.split "~"
64
+
65
+ # START HERE write a new line for each label to each label file
66
+ abort_unless doc2new_doc.has_key?(centroid_doc),
67
+ "Missing #{centroid_doc} from #{doc2new_doc}"
68
+
69
+ abort_unless doc2new_doc.has_key?(member_doc),
70
+ "Missing #{member_doc} from #{doc2new_doc}"
71
+
72
+ label2outf.keys.each do |label|
73
+ new_centroid_doc = doc2new_doc[centroid_doc][label]
74
+ new_member_doc = doc2new_doc[member_doc][label]
75
+
76
+ new_centroid = "#{new_centroid_doc}~#{centroid_seq}"
77
+ new_member = "#{new_member_doc}~#{member_seq}"
78
+ new_line = "#{new_centroid}\t#{new_member}"
79
+
80
+ label2outf[label].puts new_line
81
+ end
82
+ end
83
+
84
+ label2outf.each do |label, f|
85
+ f.close
86
+ end
87
+
88
+ label2outf.map { |labef, f| File.absolute_path f }
89
+ end
90
+ end
@@ -0,0 +1,3 @@
1
+ module Lsa
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,29 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "lsa/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "lsa"
8
+ spec.version = Lsa::VERSION
9
+ spec.authors = ["Ryan Moore"]
10
+ spec.email = ["moorer@udel.edu"]
11
+
12
+ spec.summary = %q{Latent semantic analysis pipeline for genomes and metagenomes}
13
+ spec.description = %q{Latent semantic analysis pipeline for genomes and metagenomes}
14
+ spec.homepage = "https://github.com/mooreryan/lsa"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
17
+ f.match(%r{^(test|spec|features)/})
18
+ end
19
+ spec.bindir = "exe"
20
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
21
+ spec.require_paths = ["lib"]
22
+
23
+ spec.add_runtime_dependency 'abort_if', '~> 0.2.0'
24
+
25
+ spec.add_development_dependency "bundler", "~> 1.15"
26
+ spec.add_development_dependency "rake", "~> 10.0"
27
+ spec.add_development_dependency "rspec", "~> 3.0"
28
+ spec.add_development_dependency 'guard-rspec', '~> 4.7', '>= 4.7.3'
29
+ end
@@ -0,0 +1,3 @@
1
+ e_coli_faa_gz~orf_1 e_coli_faa_gz~orf_1
2
+ e_coli_faa_gz~orf_1 m_mazei_faa_gz~orf_1
3
+ e_coli_faa_gz~orf_1 s_flexneri_faa_gz~orf_1
@@ -0,0 +1 @@
1
+ test_files/moorer@roaming-254-155.host.udel.edu.943
@@ -0,0 +1,3 @@
1
+ a~orf_1 a~orf_1
2
+ a~orf_1 a~orf_1
3
+ a~orf_1 b~orf_1
@@ -0,0 +1,3 @@
1
+ bacteria~orf_1 bacteria~orf_1
2
+ bacteria~orf_1 archaea~orf_1
3
+ bacteria~orf_1 bacteria~orf_1
@@ -0,0 +1,3 @@
1
+ e_coli_faa_gz~orf_1 e_coli_faa_gz~orf_1
2
+ e_coli_faa_gz~orf_1 m_mazei_faa_gz~orf_1
3
+ e_coli_faa_gz~orf_1 s_flexneri_faa_gz~orf_1
Binary file
Binary file
@@ -0,0 +1,4 @@
1
+ file name group another group
2
+ e_coli.faa.gz bacteria a
3
+ m_mazei.faa.gz archaea a
4
+ s_flexneri.faa.gz bacteria b
@@ -0,0 +1,15 @@
1
+ term_1 doc_1~orf
2
+ term_1 doc_1~orf
3
+ term_1 doc_1~orf
4
+ term_1 doc_2~orf
5
+ term_2 doc_1~orf
6
+ term_2 doc_2~orf
7
+ term_2 doc_2~orf
8
+ term_3 doc_1~orf
9
+ term_3 doc_2~orf
10
+ term_3 doc_3~orf
11
+ term_4 doc_4~orf
12
+ term_5 doc_1~orf
13
+ term_5 doc_2~orf
14
+ term_5 doc_3~orf
15
+ term_5 doc_4~orf
metadata ADDED
@@ -0,0 +1,148 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: lsa
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Ryan Moore
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2017-07-23 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: abort_if
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 0.2.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 0.2.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.15'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.15'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '3.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '3.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: guard-rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '4.7'
76
+ - - ">="
77
+ - !ruby/object:Gem::Version
78
+ version: 4.7.3
79
+ type: :development
80
+ prerelease: false
81
+ version_requirements: !ruby/object:Gem::Requirement
82
+ requirements:
83
+ - - "~>"
84
+ - !ruby/object:Gem::Version
85
+ version: '4.7'
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: 4.7.3
89
+ description: Latent semantic analysis pipeline for genomes and metagenomes
90
+ email:
91
+ - moorer@udel.edu
92
+ executables: []
93
+ extensions: []
94
+ extra_rdoc_files: []
95
+ files:
96
+ - ".gitignore"
97
+ - ".rspec"
98
+ - ".ruby-gemset"
99
+ - ".ruby-version"
100
+ - ".travis.yml"
101
+ - CODE_OF_CONDUCT.md
102
+ - Gemfile
103
+ - Guardfile
104
+ - LICENSE
105
+ - README.md
106
+ - Rakefile
107
+ - bin/console
108
+ - bin/setup
109
+ - lib/lsa.rb
110
+ - lib/lsa/version.rb
111
+ - lsa.gemspec
112
+ - test_files/#cluster_file.txt#
113
+ - test_files/.#cluster_file.txt
114
+ - test_files/cluster_file_another_group.txt
115
+ - test_files/cluster_file_group.txt
116
+ - test_files/cluster_file_original.txt
117
+ - test_files/e_coli.faa.gz
118
+ - test_files/m_mazei.faa.gz
119
+ - test_files/mapping.txt
120
+ - test_files/s_flexneri.faa.gz
121
+ - test_files/small/e_coli.faa.gz
122
+ - test_files/small/m_mazei.faa.gz
123
+ - test_files/small/s_flexneri.faa.gz
124
+ - test_files/test.clu.tsv
125
+ homepage: https://github.com/mooreryan/lsa
126
+ licenses: []
127
+ metadata: {}
128
+ post_install_message:
129
+ rdoc_options: []
130
+ require_paths:
131
+ - lib
132
+ required_ruby_version: !ruby/object:Gem::Requirement
133
+ requirements:
134
+ - - ">="
135
+ - !ruby/object:Gem::Version
136
+ version: '0'
137
+ required_rubygems_version: !ruby/object:Gem::Requirement
138
+ requirements:
139
+ - - ">="
140
+ - !ruby/object:Gem::Version
141
+ version: '0'
142
+ requirements: []
143
+ rubyforge_project:
144
+ rubygems_version: 2.6.12
145
+ signing_key:
146
+ specification_version: 4
147
+ summary: Latent semantic analysis pipeline for genomes and metagenomes
148
+ test_files: []