Mercurial > repos > cpt > cpt_psm_plotter
comparison lib/CPT/Circos/Conf.pm @ 1:8691c1c61a8e draft default tip
planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
author | cpt |
---|---|
date | Mon, 05 Jun 2023 02:48:47 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
0:54c7a3ea81e2 | 1:8691c1c61a8e |
---|---|
1 package CPT::Circos::Conf; | |
2 use strict; | |
3 use warnings; | |
4 use autodie; | |
5 use Moose; | |
6 | |
7 # This parameter specifies that we should behave according to galaxy_override spec. | |
8 has data => ( | |
9 is => 'rw', | |
10 isa => 'ArrayRef', | |
11 default => sub { | |
12 [] | |
13 }, | |
14 ); | |
15 my @current_block = (); | |
16 | |
17 sub set { | |
18 my ($self, $key, $value) = @_; | |
19 $self->push_d(sprintf('%s = %s', $key, $value)); | |
20 } | |
21 | |
22 sub start_block { | |
23 my ($self, $block) = @_; | |
24 $self->push_d(sprintf('<%s>', $block)); | |
25 push(@current_block, $block); | |
26 } | |
27 | |
28 sub end_block { | |
29 my ($self) = @_; | |
30 $self->push_d(sprintf('</%s>', pop @current_block)); | |
31 } | |
32 | |
33 sub include { | |
34 my ($self, $file) = @_; | |
35 $self->push_d(sprintf('<<include %s>>', $file)); | |
36 } | |
37 | |
38 sub push_d { | |
39 my ($self, $string) = @_; | |
40 push(@{$self->data()}, $self->spaces_for_indent() . $string); | |
41 } | |
42 | |
43 sub spaces_for_indent { | |
44 my ($self) = @_; | |
45 if(scalar(@current_block) > 0){ | |
46 return ' ' x scalar(@current_block); | |
47 } | |
48 return ''; | |
49 } | |
50 | |
51 sub finalize { | |
52 my ($self) = @_; | |
53 if(scalar @current_block > 0){ | |
54 die 'Blocks [' . join(',', @current_block) . '] were not closed'; | |
55 } | |
56 else{ | |
57 return join("\n", @{$self->data()}); | |
58 } | |
59 } | |
60 | |
61 no Moose::Role; | |
62 1; | |
63 | |
64 __END__ | |
65 | |
66 =pod | |
67 | |
68 =encoding UTF-8 | |
69 | |
70 =head1 NAME | |
71 | |
72 CPT::Circos::Conf | |
73 | |
74 =head1 VERSION | |
75 | |
76 version 1.99.4 | |
77 | |
78 =head1 AUTHOR | |
79 | |
80 Eric Rasche <rasche.eric@yandex.ru> | |
81 | |
82 =head1 COPYRIGHT AND LICENSE | |
83 | |
84 This software is Copyright (c) 2014 by Eric Rasche. | |
85 | |
86 This is free software, licensed under: | |
87 | |
88 The GNU General Public License, Version 3, June 2007 | |
89 | |
90 =cut |