@@ -10,6 +10,11 @@ function copy_partition_to!(dest::T, src::T) where {T<:DiscretePartition}
10
10
dest. scaling .= src. scaling
11
11
end
12
12
13
+ # Overloading the copy_partition to avoid deepcopy.
14
+ function copy_partition (src:: T ) where {T<: DiscretePartition }
15
+ return T (copy (src. state), src. states, src. sites, copy (src. scaling))
16
+ end
17
+
13
18
# I should add a constructor that constructs a DiscretePartition from an existing array.
14
19
mutable struct CustomDiscretePartition <: DiscretePartition
15
20
state:: Array{Float64,2}
@@ -24,6 +29,10 @@ mutable struct CustomDiscretePartition <: DiscretePartition
24
29
state_arr .= freq_vec
25
30
new (state_arr, length (freq_vec), sites, zeros (sites))
26
31
end
32
+ function CustomDiscretePartition (state, states, sites, scaling)
33
+ @assert size (state) == (states, sites)
34
+ new (state, states, sites, scaling)
35
+ end
27
36
end
28
37
29
38
mutable struct NucleotidePartition <: DiscretePartition
@@ -40,6 +49,10 @@ mutable struct NucleotidePartition <: DiscretePartition
40
49
state_arr .= freq_vec
41
50
new (state_arr, 4 , sites, zeros (sites))
42
51
end
52
+ function NucleotidePartition (state, states, sites, scaling)
53
+ @assert size (state) == (states, sites) && states == 4
54
+ new (state, states, sites, scaling)
55
+ end
43
56
end
44
57
45
58
mutable struct GappyNucleotidePartition <: DiscretePartition
@@ -56,6 +69,10 @@ mutable struct GappyNucleotidePartition <: DiscretePartition
56
69
state_arr .= freq_vec
57
70
new (state_arr, 5 , sites, zeros (sites))
58
71
end
72
+ function GappyNucleotidePartitionPartition (state, states, sites, scaling)
73
+ @assert size (state) == (states, sites) && states == 5
74
+ new (state, states, sites, scaling)
75
+ end
59
76
end
60
77
61
78
mutable struct AminoAcidPartition <: DiscretePartition
@@ -72,6 +89,10 @@ mutable struct AminoAcidPartition <: DiscretePartition
72
89
state_arr .= freq_vec
73
90
new (state_arr, 20 , sites, zeros (sites))
74
91
end
92
+ function AminoAcidPartition (state, states, sites, scaling)
93
+ @assert size (state) == (states, sites) && states == 20
94
+ new (state, states, sites, scaling)
95
+ end
75
96
end
76
97
77
98
mutable struct GappyAminoAcidPartition <: DiscretePartition
@@ -88,6 +109,10 @@ mutable struct GappyAminoAcidPartition <: DiscretePartition
88
109
state_arr .= freq_vec
89
110
new (state_arr, 21 , sites, zeros (sites))
90
111
end
112
+ function GappyAminoAcidPartition (state, states, sites, scaling)
113
+ @assert size (state) == (states, sites) && states == 21
114
+ new (state, states, sites, scaling)
115
+ end
91
116
end
92
117
93
118
"""
0 commit comments