This repository was archived by the owner on Oct 18, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathGeneInstance.pm
132 lines (102 loc) · 4.45 KB
/
GeneInstance.pm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
#-#####################################################################################
#- File: GeneInstance.pm
#- Synopsys: Instance of Gene
#-#####################################################################################
#- Detailed Description:
#- ---------------------
#
#-#####################################################################################
use strict;
use diagnostics; # equivalent to -w command-line switch
use warnings;
package GeneInstance;
use Class::Std::Storable;
use base qw(ParserInstance);
{
use Carp;
use Utils;
use BitString;
#######################################################################################
# ATTRIBUTES
#######################################################################################
#######################################################################################
# FUNCTIONS
#######################################################################################
my %export_flag_of :ATTR(get => 'export_flag', set => 'export_flag', default => 1);
#######################################################################################
# CLASS METHODS
#######################################################################################
#######################################################################################
# INSTANCE METHODS
#######################################################################################
#--------------------------------------------------------------------------------------
# Function: get_domains
# Synopsys:
#--------------------------------------------------------------------------------------
sub get_domains {
my $self = shift;
return @{$self->get_field_ref(["domains"])};
}
#--------------------------------------------------------------------------------------
# Function: translate_field
# Synopsys:
#--------------------------------------------------------------------------------------
sub translate_field {
my $self = shift;
my $field_name = shift;
confess "ERROR: unexpected repeat sequence" if ref $field_name;
my $transcription_ref = $self->get_transcription_ref();
my $field_ref = $transcription_ref->{$field_name};
my $field_sequence = $field_ref->[0];
my $field_int_value = bin2dec($field_sequence);
my $new_value;
SWITCH: {
if (($field_name eq "START_CODE") ||
($field_name eq "STOP_CODE") ||
($field_name eq "UNUSED")
) {
# no translation necessary
$new_value = $field_sequence;
last SWITCH;
}
if (($field_name eq "regulated_concentration")
) {
my ($max, $min);
eval "\$max = \$self->get_parent_ref->get_${field_name}_max";
eval "\$min = \$self->get_parent_ref->get_${field_name}_min";
confess "ERROR: internal error -- max not defined" if !defined $max;
confess "ERROR: internal error -- min not defined" if !defined $min;
$new_value = loglinear($min, $max, (2**length($field_sequence)) - 1, $field_int_value);
last SWITCH;
}
confess "ERROR: translate_field() -- unknown field $field_name";
} # SWITCH
return $new_value;
}
#--------------------------------------------------------------------------------------
# Function: export_anc
# Synopsys:
#--------------------------------------------------------------------------------------
sub export_anc {
my $self = shift;
my $max_count = shift;
$max_count = -1 if !defined $max_count;
confess "ERROR: sequence not translated" if (!$self->get_translation_valid_flag());
my $name = $self->get_name();
my $regulated_concentration = $self->get_translation_ref->{regulated_concentration};
my $str .= (join "\n", map {$_->[0]->export_anc()} @{$self->get_transcription_ref->{domains}});
my $elements = join(",",map {$_->[0]->get_name()} @{$self->get_transcription_ref->{domains}});
$str .= <<END;
Structure : { # IC of $name = $regulated_concentration
name => "$name",
elements => [$elements],
max_count => $max_count,
}
END
return $str;
}
}
sub run_testcases {
}
# Package BEGIN must return true value
return 1;