iroki_lib 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in iroki_lib.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.("routing/#{m[1]}_routing"),
51
+ rspec.spec.("controllers/#{m[1]}_controller"),
52
+ rspec.spec.("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.("features/#{m[1]}") }
63
+ watch(rails.layouts) { |m| rspec.spec.("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
@@ -0,0 +1,43 @@
1
+ # IrokiLib #
2
+
3
+ [![Gem Version](https://badge.fury.io/rb/iroki_lib.svg)](https://badge.fury.io/rb/iroki_lib) [![Build Status](https://travis-ci.org/mooreryan/iroki_lib.svg?branch=master)](https://travis-ci.org/mooreryan/iroki_lib) [![Coverage Status](https://coveralls.io/repos/github/mooreryan/iroki_lib/badge.svg?branch=master)](https://coveralls.io/github/mooreryan/iroki_lib?branch=master)
4
+
5
+ Library code for Iroki, a phylogenetic tree customization program.
6
+
7
+ ## Installation ##
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'iroki_lib'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install iroki_lib
22
+
23
+ ## Development ##
24
+
25
+ After checking out the repo, run `bin/setup` to install
26
+ dependencies. Then, run `rake spec` to run the tests. You can also run
27
+ `bin/console` for an interactive prompt that will allow you to
28
+ experiment.
29
+
30
+ To install this gem onto your local machine, run `bundle exec rake
31
+ install`. To release a new version, update the version number in
32
+ `version.rb`, and then run `bundle exec rake release`, which will
33
+ create a git tag for the version, push git commits and tags, and push
34
+ the `.gem` file to [rubygems.org](https://rubygems.org).
35
+
36
+ ## Contributing ##
37
+
38
+ Bug reports and pull requests are welcome on GitHub at
39
+ https://github.com/[USERNAME]/iroki_lib. This project is intended to
40
+ be a safe, welcoming space for collaboration, and contributors are
41
+ expected to adhere to the
42
+ [Contributor Covenant](http://contributor-covenant.org) code of
43
+ conduct.
@@ -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 "iroki_lib"
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
@@ -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,33 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'iroki_lib/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "iroki_lib"
8
+ spec.version = IrokiLib::VERSION
9
+ spec.authors = ["Ryan Moore"]
10
+ spec.email = ["moorer@udel.edu"]
11
+
12
+ spec.summary = %q{Library code for Iroki, a phylogenetic tree customization program.}
13
+ spec.description = %q{Library code for Iroki, a phylogenetic tree customization program.}
14
+ spec.homepage = "https://github.com/mooreryan/iroki_lib"
15
+ spec.license = "GPLv3: http://www.gnu.org/licenses/gpl.txt"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
+ spec.bindir = "exe"
19
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
+ spec.require_paths = ["lib"]
21
+
22
+ spec.required_ruby_version = ">= 2.2.4"
23
+
24
+ spec.add_development_dependency "bundler", "~> 1.11"
25
+ spec.add_development_dependency "rake", "~> 10.0"
26
+ spec.add_development_dependency "rspec", "~> 3.0"
27
+ spec.add_development_dependency "guard-rspec", "~> 4.6", ">= 4.6.4"
28
+ spec.add_development_dependency "yard", "~> 0.8.7.6"
29
+ spec.add_development_dependency "coveralls", "~> 0.8.11"
30
+
31
+ spec.add_runtime_dependency "abort_if", "~> 0.1.0"
32
+ spec.add_runtime_dependency "bio", "~> 1.5"
33
+ end
@@ -0,0 +1,42 @@
1
+ # Copyright 2016 Ryan Moore
2
+ # Contact: moorer@udel.edu
3
+ #
4
+ # This file is part of IrokiLib.
5
+ #
6
+ # IrokiLib is free software: you can redistribute it and/or modify it
7
+ # under the terms of the GNU General Public License as published by
8
+ # the Free Software Foundation, either version 3 of the License, or
9
+ # (at your option) any later version.
10
+ #
11
+ # IrokiLib is distributed in the hope that it will be useful, but
12
+ # WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
+ # General Public License for more details.
15
+ #
16
+ # You should have received a copy of the GNU General Public License
17
+ # along with IrokiLib. If not, see <http://www.gnu.org/licenses/>.
18
+
19
+ require "abort_if"
20
+
21
+ require "iroki_lib/version"
22
+ require "iroki_lib/const/const"
23
+ require "iroki_lib/color/color"
24
+ require "iroki_lib/core_ext/hash/hash"
25
+ require "iroki_lib/core_ext/string/string"
26
+ require "iroki_lib/core_ext/file/file"
27
+ require "iroki_lib/utils/utils"
28
+ require "iroki_lib/main/main"
29
+
30
+
31
+ include IrokiLib::Const
32
+ include IrokiLib::Color
33
+ include IrokiLib::CoreExt::Hash
34
+ include IrokiLib::CoreExt::String
35
+ include IrokiLib::CoreExt::File
36
+ include IrokiLib::Utils
37
+
38
+ include AbortIf
39
+
40
+
41
+ module IrokiLib
42
+ end
@@ -0,0 +1,58 @@
1
+ # Copyright 2016 Ryan Moore
2
+ # Contact: moorer@udel.edu
3
+ #
4
+ # This file is part of IrokiLib.
5
+ #
6
+ # IrokiLib is free software: you can redistribute it and/or modify it
7
+ # under the terms of the GNU General Public License as published by
8
+ # the Free Software Foundation, either version 3 of the License, or
9
+ # (at your option) any later version.
10
+ #
11
+ # IrokiLib is distributed in the hope that it will be useful, but
12
+ # WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
+ # General Public License for more details.
15
+ #
16
+ # You should have received a copy of the GNU General Public License
17
+ # along with IrokiLib. If not, see <http://www.gnu.org/licenses/>.
18
+
19
+ module IrokiLib
20
+ module Color
21
+ BASIC =
22
+ { "1" => "#FF3814", # red
23
+ "2" => "#712BFF", # blue
24
+ "3" => "#FFDF14", # yellow
25
+ "4" => "#14FF63", } # green
26
+
27
+ BASIC_LIGHT =
28
+ { "1" => "#FF8872",
29
+ "2" => "#A97FFE",
30
+ "3" => "#FFEC72",
31
+ "4" => "#71FEA1", }
32
+
33
+ BASIC_DARK =
34
+ { "1" => "#FF2800",
35
+ "2" => "#4901DD",
36
+ "3" => "#FFDD00",
37
+ "4" => "#00E24D", }
38
+
39
+ FUNKY =
40
+ { "1" => "#FF7314",
41
+ "2" => "#9F23FF",
42
+ "3" => "#FFF814",
43
+ "4" => "#14FFD8", }
44
+
45
+ FUNKY_LIGHT =
46
+ { "1" => "#FFAB72",
47
+ "2" => "#C57AFE",
48
+ "3" => "#FFFB72",
49
+ "4" => "#71FEE6", }
50
+
51
+ FUNKY_DARK =
52
+ { "1" => "#FF6700",
53
+ "2" => "#7C01DC",
54
+ "3" => "#FFF700",
55
+ "4" => "#00D7B3", }
56
+
57
+ end
58
+ end
@@ -0,0 +1,115 @@
1
+ # Copyright 2016 Ryan Moore
2
+ # Contact: moorer@udel.edu
3
+ #
4
+ # This file is part of IrokiLib.
5
+ #
6
+ # IrokiLib is free software: you can redistribute it and/or modify it
7
+ # under the terms of the GNU General Public License as published by
8
+ # the Free Software Foundation, either version 3 of the License, or
9
+ # (at your option) any later version.
10
+ #
11
+ # IrokiLib is distributed in the hope that it will be useful, but
12
+ # WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
+ # General Public License for more details.
15
+ #
16
+ # You should have received a copy of the GNU General Public License
17
+ # along with IrokiLib. If not, see <http://www.gnu.org/licenses/>.
18
+
19
+ module IrokiLib
20
+ module Const
21
+ COPYRIGHT = "2016 Ryan Moore"
22
+ CONTACT = "moorer@udel.edu"
23
+ WEBSITE = "https://github.com/mooreryan/color_tree"
24
+ LICENSE = "GPLv3"
25
+
26
+ VERSION_BANNER = " # Version: #{IrokiLib::VERSION}
27
+ # Copyright #{COPYRIGHT}
28
+ # Contact: #{CONTACT}
29
+ # Website: #{WEBSITE}
30
+ # License: #{LICENSE}"
31
+
32
+ FIG = 'begin figtree;
33
+ set appearance.backgroundColorAttribute="Default";
34
+ set appearance.backgroundColour=#-1;
35
+ set appearance.branchColorAttribute="User selection";
36
+ set appearance.branchLineWidth=1.0;
37
+ set appearance.branchMinLineWidth=0.0;
38
+ set appearance.branchWidthAttribute="Fixed";
39
+ set appearance.foregroundColour=#-16777216;
40
+ set appearance.selectionColour=#-2144520576;
41
+ set branchLabels.colorAttribute="User selection";
42
+ set branchLabels.displayAttribute="Branch times";
43
+ set branchLabels.fontName="sansserif";
44
+ set branchLabels.fontSize=8;
45
+ set branchLabels.fontStyle=0;
46
+ set branchLabels.isShown=false;
47
+ set branchLabels.significantDigits=2;
48
+ set colour.scheme.label="label:InterpolatingContinuous{{false,false,0.0,0.0},#000000,#000000}";
49
+ set layout.expansion=0;
50
+ set layout.layoutType="RECTILINEAR";
51
+ set layout.zoom=0;
52
+ set legend.attribute=null;
53
+ set legend.fontSize=10.0;
54
+ set legend.isShown=false;
55
+ set legend.significantDigits=2;
56
+ set nodeBars.barWidth=4.0;
57
+ set nodeBars.displayAttribute=null;
58
+ set nodeBars.isShown=false;
59
+ set nodeLabels.colorAttribute="label";
60
+ set nodeLabels.displayAttribute="label";
61
+ set nodeLabels.fontName="sansserif";
62
+ set nodeLabels.fontSize=8;
63
+ set nodeLabels.fontStyle=0;
64
+ set nodeLabels.isShown=true;
65
+ set nodeLabels.significantDigits=2;
66
+ set nodeShape.colourAttribute=null;
67
+ set nodeShape.isShown=false;
68
+ set nodeShape.minSize=10.0;
69
+ set nodeShape.scaleType=Width;
70
+ set nodeShape.shapeType=Circle;
71
+ set nodeShape.size=4.0;
72
+ set nodeShape.sizeAttribute=null;
73
+ set polarLayout.alignTipLabels=false;
74
+ set polarLayout.angularRange=0;
75
+ set polarLayout.rootAngle=0;
76
+ set polarLayout.rootLength=100;
77
+ set polarLayout.showRoot=true;
78
+ set radialLayout.spread=0.0;
79
+ set rectilinearLayout.alignTipLabels=false;
80
+ set rectilinearLayout.curvature=0;
81
+ set rectilinearLayout.rootLength=100;
82
+ set scale.offsetAge=0.0;
83
+ set scale.rootAge=1.0;
84
+ set scale.scaleFactor=1.0;
85
+ set scale.scaleRoot=false;
86
+ set scaleAxis.automaticScale=true;
87
+ set scaleAxis.fontSize=8.0;
88
+ set scaleAxis.isShown=false;
89
+ set scaleAxis.lineWidth=1.0;
90
+ set scaleAxis.majorTicks=1.0;
91
+ set scaleAxis.origin=0.0;
92
+ set scaleAxis.reverseAxis=false;
93
+ set scaleAxis.showGrid=true;
94
+ set scaleBar.automaticScale=true;
95
+ set scaleBar.fontSize=10.0;
96
+ set scaleBar.isShown=true;
97
+ set scaleBar.lineWidth=1.0;
98
+ set scaleBar.scaleRange=0.0;
99
+ set tipLabels.colorAttribute="User selection";
100
+ set tipLabels.displayAttribute="Names";
101
+ set tipLabels.fontName="sansserif";
102
+ set tipLabels.fontSize=8;
103
+ set tipLabels.fontStyle=0;
104
+ set tipLabels.isShown=true;
105
+ set tipLabels.significantDigits=2;
106
+ set trees.order=true;
107
+ set trees.orderType="increasing";
108
+ set trees.rooting=false;
109
+ set trees.rootingType="User Selection";
110
+ set trees.transform=false;
111
+ set trees.transformType="cladogram";
112
+ end;
113
+ '
114
+ end
115
+ end
@@ -0,0 +1,64 @@
1
+ # Copyright 2016 Ryan Moore
2
+ # Contact: moorer@udel.edu
3
+ #
4
+ # This file is part of IrokiLib.
5
+ #
6
+ # IrokiLib is free software: you can redistribute it and/or modify it
7
+ # under the terms of the GNU General Public License as published by
8
+ # the Free Software Foundation, either version 3 of the License, or
9
+ # (at your option) any later version.
10
+ #
11
+ # IrokiLib is distributed in the hope that it will be useful, but
12
+ # WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
+ # General Public License for more details.
15
+ #
16
+ # You should have received a copy of the GNU General Public License
17
+ # along with IrokiLib. If not, see <http://www.gnu.org/licenses/>.
18
+
19
+ module IrokiLib
20
+ module CoreExt
21
+ module File
22
+ def check_file arg, which
23
+ help = " Try color_tree --help for help."
24
+
25
+ abort_if arg.nil?,
26
+ "You must provide a #{which} file.#{help}"
27
+
28
+ abort_unless Object::File.exists?(arg),
29
+ "The file #{arg} doesn't exist.#{help}"
30
+
31
+ arg
32
+ end
33
+
34
+ def parse_name_map fname
35
+ check_file fname, :name_map
36
+
37
+ name_map = {}
38
+ Object::File.open(fname).each_line do |line|
39
+ oldname, newname = line.chomp.split "\t"
40
+
41
+
42
+ abort_if oldname.nil? || oldname.empty?,
43
+ "Column 1 missing for line: #{line.inspect}"
44
+
45
+ abort_if newname.nil? || newname.empty?,
46
+ "Column 2 missing for line: #{line.inspect}"
47
+
48
+ oldname = clean oldname
49
+ newname = clean newname
50
+
51
+ abort_if name_map.has_key?(oldname),
52
+ "#{oldname} is repeated in column 1"
53
+
54
+ name_map[oldname] = newname
55
+ end
56
+
57
+ abort_if duplicate_values?(name_map),
58
+ "Names in column 2 of name map file must be unique"
59
+
60
+ name_map
61
+ end
62
+ end
63
+ end
64
+ end