diff --git a/pyproject.toml b/pyproject.toml index 4ed603d..60bc1cc 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -16,7 +16,7 @@ maintainers = [ ] name = "lineagetree" description = "Structure for Lineage Trees" -version = "3.1.0" +version = "3.2.0" license = "MIT" license-files = [ "LICENSE" ] readme = {file = "README.md", content-type = "text/markdown"} @@ -76,7 +76,7 @@ profile = "black" line_length = 79 [tool.bumpver] -current_version = "3.1.0" +current_version = "3.2.0" version_pattern = "MAJOR.MINOR.PATCH[-TAG]" commit_message = "bump version {old_version} -> {new_version}" commit = true diff --git a/src/lineagetree/__init__.py b/src/lineagetree/__init__.py index b72ddcd..6cdc63f 100644 --- a/src/lineagetree/__init__.py +++ b/src/lineagetree/__init__.py @@ -1,4 +1,4 @@ -__version__ = "3.1.0" +__version__ = "3.2.0" from .lineage_tree import LineageTree from ._io._loaders import ( read_from_ASTEC, @@ -12,6 +12,7 @@ read_from_txt_for_celegans, read_from_txt_for_celegans_BAO, read_from_txt_for_celegans_CAO, + read_from_swc, LOADERS, ) from .lineage_tree_manager import LineageTreeManager @@ -30,5 +31,6 @@ "read_from_mastodon", "read_from_txt_for_celegans", "read_from_txt_for_celegans_CAO", + "read_from_swc", "LOADERS", ) diff --git a/src/lineagetree/_core/_properties.py b/src/lineagetree/_core/_properties.py index 67eacf7..348ce52 100644 --- a/src/lineagetree/_core/_properties.py +++ b/src/lineagetree/_core/_properties.py @@ -222,3 +222,10 @@ def parenting(lT: LineageTree): lT._tmp_parenting[(i, j)] = _m(lT, i, j) del lT._tmp_parenting return lT._parenting + + +@property +def temporal(lT: LineageTree): + if not hasattr(lT, "_temporal"): + lT._temporal = True + return lT._temporal diff --git a/src/lineagetree/_io/_loaders.py b/src/lineagetree/_io/_loaders.py index 2b87710..e450c13 100644 --- a/src/lineagetree/_io/_loaders.py +++ b/src/lineagetree/_io/_loaders.py @@ -1064,6 +1064,39 @@ def read_from_mamut_xml( ) +def read_from_swc(swc_path: Path | str) -> LineageTree: + """ + Read a neuronal tree from a swc file + """ + with open(swc_path) as f: + lines = f.readlines() + + predecessor = {} + pos = {} + properties = {} + properties["radius"] = {} + properties["structure_id"] = {} + for line in lines: + line = line.strip() + if len(line) < 1 or line[0] == "#": + continue + id_, struct_id, x, y, z, rad, parent = [ + eval(li) for li in line.split() + ] + predecessor[id_] = parent + pos[id_] = np.array([x, y, z]) + properties["radius"][id_] = rad + properties["structure_id"][id_] = struct_id + + return LineageTree( + predecessor=predecessor, + pos=pos, + root_leaf_value=(-1,), + temporal=False, + **properties, + ) + + LOADERS = { # put all formats in smaller case "bmf": { "BMF loader": read_from_bmf, @@ -1091,4 +1124,7 @@ def read_from_mamut_xml( "C. elegans CAO loader": read_from_txt_for_celegans_CAO, "C. elegans BAO loader": read_from_txt_for_celegans_BAO, }, + "swc": { + "Neurons format": read_from_swc, + }, } diff --git a/src/lineagetree/_mixins/properties_mixin.py b/src/lineagetree/_mixins/properties_mixin.py index f88a01a..bf3d3c3 100644 --- a/src/lineagetree/_mixins/properties_mixin.py +++ b/src/lineagetree/_mixins/properties_mixin.py @@ -12,6 +12,7 @@ successor, t_b, t_e, + temporal, time, time_nodes, time_resolution, @@ -39,3 +40,4 @@ class PropertiesMixin(metaclass=AutoMethodizeMeta): all_chains = all_chains time_nodes = time_nodes parenting = parenting + temporal = temporal diff --git a/src/lineagetree/lineage_tree.py b/src/lineagetree/lineage_tree.py index 47eff18..3699928 100644 --- a/src/lineagetree/lineage_tree.py +++ b/src/lineagetree/lineage_tree.py @@ -100,6 +100,8 @@ def load(clf, fname: str): lT.time_resolution = 1 if not hasattr(lT, "spatial_resolution"): lT.spatial_resolution = np.ones(3) + if not hasattr(lT, "_temporal"): + lT._temporal = True return lT @@ -146,6 +148,7 @@ def __init__( name: str | None = None, root_leaf_value: Sequence | None = None, spatial_resolution: Sequence | None = None, + temporal: bool = True, **kwargs, ): """Create a LineageTree object from minimal information, without reading from a file. @@ -169,12 +172,15 @@ def __init__( root_leaf_value : Iterable, optional Iterable of values of roots' predecessors and leaves' successors in the successor and predecessor dictionaries. Defaults are `[None, (), [], set()]`. + temporal : boolean, default `True` + Whether the tree structure has time **kwargs: Supported keyword arguments are dictionaries assigning nodes to any custom property. The property must be specified for every node, and named differently from LineageTree's own attributes. """ self.__version__ = importlib.metadata.version("lineagetree") self.name = str(name) if name is not None else None + self._temporal = temporal self._validator = TreeValidator(self) diff --git a/tests/data/204-2-6nj.CNG.swc b/tests/data/204-2-6nj.CNG.swc new file mode 100644 index 0000000..41f9864 --- /dev/null +++ b/tests/data/204-2-6nj.CNG.swc @@ -0,0 +1,609 @@ +# Original file 204-2-6nj.swc edited using StdSwc version 1.31 on 4/23/14. +# Irregularities and fixes documented in 204-2-6nj.swc.std. See StdSwc1.31.doc for more information. +# +# Neurolucida to SWC conversion from L-Measure. Sridevi Polavaram: spolavar@gmu.edu +# Original fileName:C:\Users\praveen\Desktop\DataProcessing\CurrentArchives\Processing\Jacobs-2\ASC\204-2-6nj.asc +#The original file has a single soma contour that is averaged into 3 soma points +1 1 0.0 0.0 0.0 5.2517 -1 +2 1 -1.44 -5.01 -0.57 5.2517 1 +3 1 1.44 5.01 0.57 5.2517 1 +4 3 0.96 6.58 0.41 0.425 1 +5 3 3.06 8.23 -2.63 0.425 4 +6 3 2.31 11.13 -2.78 0.425 5 +7 3 0.81 13.25 -0.15 0.305 6 +8 3 -0.74 15.2 1.15 0.305 7 +9 3 -2.45 18.45 3.66 0.485 8 +10 3 -2.35 19.26 6.31 0.245 9 +11 3 -2.21 19.35 6.35 0.245 10 +12 3 -2.21 23.84 4.8 0.305 11 +13 3 -3.74 25.9 5.14 0.245 12 +14 3 -3.67 29.03 3.15 0.245 13 +15 3 -3.67 33.33 3.36 0.245 14 +16 3 -3.39 38.49 2.08 0.18 15 +17 3 -4.12 42.07 3.72 0.18 16 +18 3 -6.73 43.43 2.81 0.18 17 +19 3 -6.64 45.44 2.91 0.18 18 +20 3 -5.48 47.73 3.3 0.18 19 +21 3 -6.01 49.24 3.63 0.18 20 +22 3 -7.61 49.73 3.32 0.18 21 +23 3 -8.39 51.71 4.74 0.18 22 +24 3 -8.33 54.09 4.9 0.18 23 +25 3 -9.23 56.91 4.76 0.18 24 +26 3 -9.68 60.54 6.38 0.18 25 +27 3 -11.8 62.72 7.18 0.18 26 +28 3 -13.34 65.06 9.39 0.18 27 +29 3 -14.11 67.07 9.31 0.18 28 +30 3 -13.39 68.74 9.57 0.18 29 +31 3 -14.0 69.57 9.43 0.18 30 +32 3 -12.31 72.46 10.0 0.18 31 +33 3 -9.37 77.29 8.12 0.18 32 +34 3 -10.5 78.91 7.88 0.18 33 +35 3 -11.11 59.05 3.03 0.18 25 +36 3 -14.21 61.81 1.16 0.18 35 +37 3 -14.67 62.55 -0.69 0.18 36 +38 3 -18.35 64.33 -2.55 0.18 37 +39 3 -20.21 66.93 -2.8 0.18 38 +40 3 -20.34 68.45 -3.51 0.18 39 +41 3 -21.35 69.18 -6.29 0.18 40 +42 3 -22.73 70.76 -6.61 0.18 41 +43 3 -27.07 71.38 -8.84 0.18 42 +44 3 -31.55 70.26 -12.17 0.18 43 +45 3 -15.59 66.78 -3.11 0.12 37 +46 3 -16.08 66.79 -4.23 0.12 45 +47 3 -3.15 36.26 6.51 0.245 15 +48 3 -3.05 42.18 8.89 0.18 47 +49 3 -1.4 45.84 9.52 0.18 48 +50 3 -0.65 46.73 9.76 0.18 49 +51 3 1.14 51.2 7.3 0.18 50 +52 3 3.02 52.62 7.86 0.18 51 +53 3 4.69 56.32 6.95 0.18 52 +54 3 5.59 57.29 7.22 0.18 53 +55 3 6.69 57.32 7.57 0.18 54 +56 3 6.73 59.44 10.0 0.18 55 +57 3 9.08 61.22 10.75 0.18 56 +58 3 9.61 63.86 12.96 0.18 57 +59 3 10.87 64.85 13.39 0.12 58 +60 3 10.36 65.65 13.28 0.12 59 +61 3 11.92 67.53 15.12 0.12 60 +62 3 13.14 68.78 15.5 0.12 61 +63 3 13.22 69.9 15.56 0.12 62 +64 3 1.55 48.5 10.99 0.18 50 +65 3 1.56 48.99 11.06 0.18 64 +66 3 5.36 50.86 11.85 0.18 65 +67 3 6.22 51.72 12.11 0.18 66 +68 3 7.83 53.48 12.61 0.18 67 +69 3 9.29 54.29 13.04 0.18 68 +70 3 10.55 55.66 13.43 0.18 69 +71 3 11.97 55.46 13.75 0.18 70 +72 3 2.13 51.4 11.82 0.245 65 +73 3 2.69 54.66 14.17 0.245 72 +74 3 1.14 56.55 14.91 0.245 73 +75 3 2.02 58.8 15.28 0.245 74 +76 3 1.76 61.02 16.49 0.245 75 +77 3 -7.38 25.94 4.05 0.18 13 +78 3 -8.16 25.94 1.51 0.18 77 +79 3 0.92 23.8 1.76 0.245 12 +80 3 1.64 27.48 -1.06 0.245 79 +81 3 2.14 29.54 -1.47 0.245 80 +82 3 0.85 31.19 -2.58 0.245 81 +83 3 1.44 34.08 -4.85 0.245 82 +84 3 0.46 35.04 -7.47 0.245 83 +85 3 0.52 37.31 -7.42 0.18 84 +86 3 -0.98 40.58 -7.71 0.18 85 +87 3 -0.82 43.88 -10.34 0.18 86 +88 3 -1.11 45.87 -10.34 0.18 87 +89 3 -3.39 46.85 -10.92 0.18 88 +90 3 -3.85 48.65 -10.98 0.18 89 +91 3 -0.37 19.77 6.86 0.245 11 +92 3 1.97 22.47 5.16 0.245 91 +93 3 3.86 26.04 5.8 0.245 92 +94 3 3.27 26.99 5.73 0.245 93 +95 3 7.46 32.61 7.07 0.245 94 +96 3 9.05 36.31 9.56 0.245 95 +97 3 9.3 38.01 9.69 0.245 96 +98 3 12.46 38.77 10.57 0.245 97 +99 3 12.06 41.76 13.27 0.245 98 +100 3 13.4 44.21 16.21 0.245 99 +101 3 15.32 48.31 18.9 0.245 100 +102 3 17.59 50.73 19.71 0.245 101 +103 3 19.54 52.01 20.28 0.245 102 +104 3 21.01 52.81 20.71 0.245 103 +105 3 20.23 56.48 20.64 0.245 104 +106 3 17.7 59.36 21.82 0.245 105 +107 3 18.34 61.84 21.83 0.245 106 +108 3 18.65 64.31 20.66 0.245 107 +109 3 18.47 66.03 19.43 0.245 108 +110 3 18.56 70.56 19.57 0.245 109 +111 3 6.16 34.04 6.78 0.18 95 +112 3 6.2 36.73 5.38 0.18 111 +113 3 4.92 37.98 3.27 0.18 112 +114 3 5.85 41.55 3.03 0.18 113 +115 3 4.66 44.6 2.77 0.18 114 +116 3 3.27 45.3 2.42 0.18 115 +117 3 3.22 46.61 2.2 0.18 116 +118 3 5.18 49.52 0.76 0.18 117 +119 3 6.09 52.19 -1.53 0.18 118 +120 3 5.41 57.02 -3.09 0.18 119 +121 3 -5.04 19.47 5.79 0.305 9 +122 3 -5.66 20.29 5.66 0.305 121 +123 3 -6.03 19.02 5.51 0.305 122 +124 3 -9.52 20.36 5.96 0.245 123 +125 3 -12.48 20.48 7.92 0.245 124 +126 3 -15.56 19.69 9.23 0.245 125 +127 3 -18.98 20.9 11.77 0.245 126 +128 3 -22.35 23.03 12.7 0.245 127 +129 3 -23.75 25.0 12.45 0.18 128 +130 3 -24.81 26.6 8.9 0.18 129 +131 3 -24.82 27.82 3.82 0.18 130 +132 3 3.99 13.13 -2.25 0.425 6 +133 3 8.38 12.62 -1.08 0.425 132 +134 3 10.77 11.98 -0.46 0.425 133 +135 3 16.63 15.27 3.77 0.425 134 +136 3 18.43 17.07 4.59 0.245 135 +137 3 19.34 21.08 4.98 0.245 136 +138 3 23.71 24.37 6.39 0.245 137 +139 3 24.83 25.66 6.69 0.245 138 +140 3 25.67 29.44 7.06 0.245 139 +141 3 27.19 31.74 7.55 0.245 140 +142 3 30.87 36.4 8.72 0.245 141 +143 3 32.81 36.77 10.04 0.245 142 +144 3 35.24 37.74 10.99 0.245 143 +145 3 35.71 38.34 13.42 0.245 144 +146 3 36.41 41.0 15.05 0.18 145 +147 3 37.97 40.79 17.38 0.18 146 +148 3 39.86 47.2 21.03 0.18 147 +149 3 40.78 49.62 21.95 0.18 148 +150 3 41.74 51.22 22.26 0.18 149 +151 3 44.09 51.73 22.92 0.18 150 +152 3 45.7 52.07 24.71 0.18 151 +153 3 46.62 52.81 27.11 0.18 152 +154 3 40.68 46.09 23.08 0.18 148 +155 3 41.94 44.55 23.37 0.18 154 +156 3 43.14 43.44 24.48 0.18 155 +157 3 29.51 38.67 8.44 0.245 142 +158 3 30.43 41.63 6.98 0.245 157 +159 3 30.7 43.82 7.13 0.18 158 +160 3 29.85 45.98 6.99 0.18 159 +161 3 29.21 46.69 4.77 0.18 160 +162 3 31.7 52.29 5.08 0.18 161 +163 3 32.39 54.54 3.64 0.18 162 +164 3 33.1 55.71 3.87 0.18 163 +165 3 35.35 57.14 4.54 0.18 164 +166 3 34.35 59.81 8.15 0.18 165 +167 3 33.55 60.54 6.04 0.18 166 +168 3 33.81 62.73 6.24 0.18 167 +169 3 29.8 64.13 5.21 0.245 168 +170 3 27.4 65.02 1.38 0.245 169 +171 3 26.15 67.9 2.65 0.245 170 +172 3 28.03 74.0 2.4 0.245 171 +173 3 28.81 75.78 2.63 0.245 172 +174 3 27.9 78.63 5.55 0.245 173 +175 3 29.19 80.61 6.07 0.245 174 +176 3 29.17 82.65 6.14 0.245 175 +177 3 26.47 74.5 1.95 0.18 172 +178 3 24.89 75.39 1.55 0.18 177 +179 3 22.89 75.26 1.01 0.18 178 +180 3 35.92 61.46 8.68 0.18 166 +181 3 37.51 63.99 9.21 0.18 180 +182 3 38.28 64.36 11.76 0.18 181 +183 3 40.43 63.3 12.3 0.18 182 +184 3 41.47 63.1 12.58 0.18 183 +185 3 41.46 62.02 15.33 0.18 184 +186 3 44.67 61.24 16.17 0.18 185 +187 3 45.87 61.62 16.56 0.18 186 +188 3 47.72 61.66 17.06 0.18 187 +189 3 47.89 64.24 19.59 0.18 188 +190 3 50.32 63.41 21.82 0.18 189 +191 3 37.56 65.49 9.33 0.18 181 +192 3 39.04 68.05 9.82 0.18 191 +193 3 40.1 69.61 10.17 0.18 192 +194 3 40.38 72.69 10.36 0.18 193 +195 3 42.82 75.96 10.05 0.18 194 +196 3 42.68 78.91 10.17 0.18 195 +197 3 45.2 85.96 11.12 0.18 196 +198 3 17.33 13.52 3.95 0.365 135 +199 3 19.83 13.52 6.44 0.305 198 +200 3 21.85 13.12 9.31 0.245 199 +201 3 22.84 13.79 10.89 0.245 200 +202 3 24.63 14.1 11.44 0.245 201 +203 3 26.33 15.12 12.71 0.245 202 +204 3 27.46 14.96 15.76 0.245 203 +205 3 26.87 16.51 16.9 0.18 204 +206 3 28.32 18.09 17.3 0.18 205 +207 3 30.67 19.86 18.0 0.18 206 +208 3 33.36 21.93 18.81 0.18 207 +209 3 33.83 21.85 20.43 0.18 208 +210 3 35.67 22.03 23.17 0.18 209 +211 3 38.24 22.93 26.49 0.18 210 +212 3 42.24 22.57 28.38 0.18 211 +213 3 30.13 12.82 16.51 0.245 204 +214 3 32.21 13.03 18.32 0.245 213 +215 3 33.77 14.17 18.84 0.18 214 +216 3 34.5 15.7 21.37 0.18 215 +217 3 37.15 17.65 22.21 0.18 216 +218 3 39.34 18.46 22.83 0.18 217 +219 3 40.68 17.14 23.15 0.18 218 +220 3 0.09 -14.61 5.5 0.245 1 +221 3 1.13 -18.05 5.66 0.245 220 +222 3 2.28 -20.43 5.88 0.245 221 +223 3 2.38 -24.27 5.81 0.18 222 +224 3 1.5 -29.43 5.39 0.18 223 +225 3 -0.19 -33.2 4.79 0.18 224 +226 3 -0.7 -37.47 4.54 0.18 225 +227 3 -3.47 -38.45 3.39 0.18 226 +228 3 -2.67 -43.62 1.03 0.12 227 +229 3 -5.01 -47.75 1.91 0.12 228 +230 3 -5.57 -50.99 1.63 0.18 229 +231 3 -6.79 -53.51 1.21 0.18 230 +232 3 -6.77 -55.16 1.15 0.18 231 +233 3 -6.94 -55.74 1.09 0.18 232 +234 3 -7.75 -58.01 2.91 0.18 233 +235 3 -6.95 -60.4 3.04 0.18 234 +236 3 -3.03 -62.84 0.07 0.18 235 +237 3 -0.79 -63.56 0.64 0.18 236 +238 3 0.66 -64.92 -1.07 0.18 237 +239 3 1.85 -65.05 -0.76 0.18 238 +240 3 5.39 -63.82 -4.83 0.18 239 +241 3 8.4 -64.43 -7.1 0.18 240 +242 3 10.3 -65.28 -7.86 0.18 241 +243 3 13.23 -65.02 -9.76 0.18 242 +244 3 11.69 -64.2 -5.32 0.18 243 +245 3 18.12 -63.84 -14.51 0.18 244 +246 3 22.93 -64.52 -14.17 0.18 245 +247 3 24.51 -62.01 -16.7 0.18 246 +248 3 26.82 -60.84 -16.09 0.18 247 +249 3 29.48 -60.55 -15.36 0.18 248 +250 3 31.44 -56.74 -14.68 0.18 249 +251 3 34.9 -56.54 -15.14 0.18 250 +252 3 38.21 -52.57 -14.93 0.18 251 +253 3 40.12 -52.29 -14.4 0.18 252 +254 3 42.57 -52.31 -13.74 0.18 253 +255 3 42.99 -51.3 -13.59 0.18 254 +256 3 45.47 -51.21 -12.92 0.18 255 +257 3 48.73 -50.33 -13.3 0.18 256 +258 3 50.41 -50.32 -13.21 0.18 257 +259 3 53.26 -48.01 -12.71 0.18 258 +260 3 56.87 -48.4 -13.0 0.18 259 +261 3 60.66 -49.27 -10.45 0.18 260 +262 3 62.62 -47.04 -6.11 0.18 261 +263 3 65.34 -47.38 -4.4 0.18 262 +264 3 66.88 -45.78 -2.26 0.18 263 +265 3 70.3 -43.52 0.44 0.18 264 +266 3 73.43 -43.57 3.98 0.18 265 +267 3 75.0 -45.94 5.15 0.18 266 +268 3 79.08 -46.37 8.62 0.18 267 +269 3 80.95 -45.71 10.34 0.18 268 +270 3 85.69 -49.57 15.16 0.18 269 +271 3 87.52 -51.67 15.63 0.18 270 +272 3 90.52 -52.75 16.4 0.18 271 +273 3 94.12 -53.01 17.36 0.18 272 +274 3 95.32 -55.18 17.66 0.18 273 +275 3 97.39 -56.47 18.17 0.18 274 +276 3 103.08 -56.76 19.69 0.18 275 +277 3 106.27 -59.68 20.45 0.18 276 +278 3 108.48 -58.33 26.28 0.18 277 +279 3 113.88 -58.77 27.67 0.18 278 +280 3 116.24 -59.52 28.28 0.18 279 +281 3 118.71 -60.7 28.91 0.18 280 +282 3 82.7 -43.37 11.01 0.18 269 +283 3 84.16 -41.85 11.77 0.18 282 +284 3 87.68 -41.57 12.73 0.18 283 +285 3 91.15 -41.06 17.21 0.18 284 +286 3 92.65 -40.54 18.67 0.18 285 +287 3 95.37 -41.28 19.38 0.18 286 +288 3 98.17 -40.0 16.71 0.18 287 +289 3 100.7 -40.56 17.37 0.18 288 +290 3 102.9 -40.62 17.97 0.18 289 +291 3 108.13 -39.93 14.28 0.18 290 +292 3 110.86 -39.4 15.03 0.18 291 +293 3 113.1 -40.12 15.61 0.18 292 +294 3 113.41 -41.61 15.64 0.18 293 +295 3 19.86 -60.73 -19.47 0.18 245 +296 3 22.5 -55.95 -21.22 0.18 295 +297 3 23.48 -53.35 -20.81 0.18 296 +298 3 24.18 -50.92 -20.53 0.18 297 +299 3 24.07 -48.49 -17.1 0.18 298 +300 3 24.12 -44.73 -16.73 0.18 299 +301 3 24.21 -41.46 -16.59 0.18 300 +302 3 27.05 -38.76 -20.7 0.18 301 +303 3 28.41 -34.89 -20.19 0.18 302 +304 3 27.74 -32.14 -20.26 0.18 303 +305 3 28.07 -31.48 -20.2 0.18 304 +306 3 26.76 -27.52 -20.41 0.18 305 +307 3 -6.84 -61.4 3.03 0.18 235 +308 3 -8.29 -62.77 2.74 0.18 307 +309 3 -12.51 -60.98 6.54 0.18 308 +310 3 -16.6 -60.44 9.86 0.18 309 +311 3 -21.32 -60.97 14.26 0.18 310 +312 3 -27.04 -58.5 18.15 0.18 311 +313 3 -33.47 -56.45 24.21 0.18 312 +314 3 -37.61 -55.54 26.65 0.18 313 +315 3 -40.47 -55.28 23.86 0.18 314 +316 3 -43.74 -53.62 18.74 0.18 315 +317 3 -45.16 -52.32 17.73 0.18 316 +318 3 -24.83 -58.62 24.7 0.18 311 +319 3 -28.59 -56.22 32.02 0.18 318 +320 3 -29.35 -55.85 31.87 0.245 319 +321 3 -32.37 -47.16 32.42 0.18 320 +322 3 -33.12 -44.21 31.91 0.18 321 +323 3 -30.9 -37.51 31.05 0.18 322 +324 3 -30.38 -33.24 31.3 0.18 323 +325 3 -28.62 -29.24 31.92 0.18 324 +326 3 -29.12 -25.53 31.87 0.18 325 +327 3 -29.36 -24.38 29.1 0.18 326 +328 3 -28.68 -22.06 29.32 0.18 327 +329 3 -30.25 -19.42 26.98 0.18 328 +330 3 -31.4 -16.27 26.73 0.18 329 +331 3 -34.34 -11.16 26.12 0.18 330 +332 3 -35.35 -11.12 25.02 0.18 331 +333 3 -35.55 -7.7 23.39 0.18 332 +334 3 -36.03 -1.61 23.64 0.12 333 +335 3 -35.71 4.5 23.85 0.18 334 +336 3 -36.35 8.24 22.83 0.18 335 +337 3 -35.5 11.43 26.03 0.18 336 +338 3 -35.29 19.84 26.45 0.18 337 +339 3 -35.48 21.3 26.45 0.18 338 +340 3 -32.54 24.18 28.24 0.18 339 +341 3 -31.97 28.4 27.71 0.18 340 +342 3 -32.33 31.9 25.78 0.18 341 +343 3 -31.0 35.16 26.21 0.18 342 +344 3 -31.67 38.02 26.24 0.18 343 +345 3 -29.7 38.92 27.84 0.18 344 +346 3 -38.21 -6.84 22.59 0.18 333 +347 3 -42.69 -4.53 20.43 0.18 346 +348 3 -42.79 0.91 21.96 0.18 347 +349 3 -43.74 3.27 20.39 0.18 348 +350 3 -42.84 5.9 20.73 0.18 349 +351 3 -44.76 8.15 19.21 0.18 350 +352 3 -42.54 11.51 19.88 0.18 351 +353 3 -41.74 15.41 22.57 0.18 352 +354 3 -43.35 17.25 23.97 0.18 353 +355 3 -43.65 20.83 24.49 0.18 354 +356 3 -44.77 25.23 26.63 0.12 355 +357 3 -48.84 26.6 29.36 0.12 356 +358 3 -50.07 28.22 31.58 0.12 357 +359 3 -6.84 -61.6 3.07 0.18 307 +360 3 -6.73 -63.7 3.03 0.18 359 +361 3 -7.79 -64.11 -4.0 0.18 360 +362 3 -12.75 -63.28 -3.09 0.18 361 +363 3 -15.57 -65.65 -4.2 0.18 362 +364 3 -17.13 -65.48 -5.08 0.18 363 +365 3 -18.55 -67.0 -6.03 0.18 364 +366 3 -20.6 -70.99 -8.08 0.18 365 +367 3 -19.27 -76.72 -8.09 0.18 366 +368 3 -20.64 -82.16 -5.97 0.18 367 +369 3 -18.68 -86.5 -5.24 0.18 368 +370 3 -18.58 -86.26 -4.27 0.18 369 +371 3 -16.37 -87.39 -5.32 0.12 370 +372 3 -12.35 -87.89 -9.8 0.18 371 +373 3 -5.74 -88.56 -19.49 0.18 372 +374 3 -1.21 -86.79 -24.16 0.18 373 +375 3 1.77 -89.62 -28.07 0.18 374 +376 3 5.39 -90.63 -30.6 0.18 375 +377 3 -21.74 -89.76 -3.49 0.18 370 +378 3 -24.2 -95.31 -4.36 0.18 377 +379 3 -24.65 -101.11 -4.7 0.18 378 +380 3 -23.92 -103.88 -1.29 0.18 379 +381 3 -22.71 -106.67 2.24 0.18 380 +382 3 -23.58 -111.52 5.71 0.18 381 +383 3 -21.99 -114.5 6.55 0.18 382 +384 3 -19.78 -124.97 6.91 0.18 383 +385 3 -16.39 -127.92 7.72 0.18 384 +386 3 -16.96 -128.89 7.68 0.18 385 +387 3 -13.92 -129.85 9.46 0.18 386 +388 3 -10.51 -129.92 10.38 0.18 387 +389 3 -7.95 -129.46 13.21 0.12 388 +390 3 -4.39 -128.58 14.26 0.12 389 +391 3 -2.32 -128.58 17.92 0.12 390 +392 3 3.89 -127.79 19.69 0.12 391 +393 3 6.09 -128.62 20.3 0.12 392 +394 3 10.89 -128.32 23.37 0.12 393 +395 3 13.23 -127.11 29.03 0.12 394 +396 3 16.83 -126.65 31.41 0.12 395 +397 3 19.48 -125.08 33.23 0.12 396 +398 3 21.78 -124.5 35.73 0.12 397 +399 3 24.87 -123.08 37.71 0.12 398 +400 3 28.27 -122.98 39.36 0.12 399 +401 3 30.55 -122.51 42.79 0.12 400 +402 3 33.48 -122.43 45.76 0.12 401 +403 3 37.64 -121.85 49.14 0.12 402 +404 3 41.3 -122.54 52.43 0.12 403 +405 3 -18.28 -135.15 10.15 0.245 386 +406 3 -17.84 -141.33 12.01 0.245 405 +407 3 -18.57 -146.93 14.98 0.245 406 +408 3 -20.07 -155.37 17.99 0.245 407 +409 3 -20.8 -165.14 22.98 0.245 408 +410 3 -18.49 -169.81 24.51 0.245 409 +411 3 -17.69 -176.31 27.13 0.245 410 +412 3 -14.92 -186.69 33.04 0.245 411 +413 3 -6.18 -63.97 1.14 0.18 360 +414 3 -6.15 -67.28 1.03 0.18 413 +415 3 -5.21 -68.71 1.23 0.18 414 +416 2 1.94 -6.5 0.19 1.215 1 +417 2 0.73 -10.8 4.16 0.91 416 +418 2 0.47 -12.42 5.69 0.91 417 +419 2 3.26 -12.04 8.89 0.365 418 +420 2 8.17 -11.5 12.88 0.365 419 +421 2 12.21 -10.63 15.04 0.365 420 +422 2 15.52 -9.82 17.47 0.365 421 +423 2 16.64 -10.2 22.27 0.365 422 +424 2 18.14 -8.95 23.13 0.365 423 +425 2 20.8 -10.47 24.11 0.365 424 +426 2 31.59 -12.73 28.81 0.425 425 +427 2 32.38 -10.44 29.99 0.18 426 +428 2 35.14 -10.13 31.36 0.18 427 +429 2 38.59 -10.73 34.5 0.18 428 +430 2 41.5 -10.4 35.35 0.18 429 +431 2 42.92 -10.59 35.73 0.18 430 +432 2 44.65 -8.78 38.86 0.18 431 +433 2 46.57 -4.71 39.52 0.18 432 +434 2 45.15 -2.8 39.73 0.18 433 +435 2 44.67 -0.62 39.68 0.245 434 +436 2 43.67 2.72 39.59 0.245 435 +437 2 42.83 6.05 40.37 0.245 436 +438 2 42.44 8.64 40.98 0.245 437 +439 2 41.77 9.18 41.23 0.245 438 +440 2 42.29 11.92 41.53 0.245 439 +441 2 42.12 13.44 42.06 0.245 440 +442 2 41.61 15.86 39.93 0.245 441 +443 2 41.4 18.97 39.99 0.245 442 +444 2 43.73 21.91 40.68 0.245 443 +445 2 44.46 23.57 40.94 0.245 444 +446 2 43.03 27.95 40.72 0.245 445 +447 2 40.51 31.73 36.34 0.245 446 +448 2 39.16 36.27 35.37 0.245 447 +449 2 35.36 38.64 33.18 0.245 448 +450 2 34.96 41.8 31.02 0.18 449 +451 2 35.18 43.69 29.49 0.18 450 +452 2 33.32 45.98 30.83 0.18 451 +453 2 35.08 48.98 31.31 0.18 452 +454 2 37.99 51.78 30.6 0.18 453 +455 2 38.95 52.11 30.87 0.18 454 +456 2 38.85 55.98 28.4 0.18 455 +457 2 38.74 58.2 26.01 0.18 456 +458 2 38.98 63.2 26.11 0.18 457 +459 2 38.08 65.13 25.94 0.18 458 +460 2 39.08 67.02 26.9 0.18 459 +461 2 39.94 70.37 28.76 0.18 460 +462 2 32.7 -14.61 31.32 0.365 426 +463 2 36.18 -15.29 32.65 0.18 462 +464 2 41.04 -14.17 34.0 0.18 463 +465 2 41.73 -13.87 36.27 0.18 464 +466 2 44.31 -14.79 38.85 0.18 465 +467 2 47.15 -14.88 42.47 0.18 466 +468 2 48.05 -15.03 45.92 0.18 467 +469 2 50.56 -14.59 47.91 0.18 468 +470 2 51.93 -14.6 51.18 0.18 469 +471 2 53.23 -14.63 53.76 0.18 470 +472 2 53.96 -14.93 56.64 0.18 471 +473 2 55.93 -15.07 58.46 0.18 472 +474 2 35.0 -19.13 36.12 0.305 462 +475 2 34.88 -22.79 36.16 0.305 474 +476 2 36.32 -24.08 37.12 0.305 475 +477 2 36.83 -27.9 38.05 0.305 476 +478 2 34.59 -32.57 37.9 0.305 477 +479 2 33.6 -35.05 38.68 0.245 478 +480 2 33.25 -38.83 40.41 0.245 479 +481 2 34.37 -42.87 41.76 0.245 480 +482 2 34.7 -45.06 43.37 0.245 481 +483 2 33.96 -46.72 45.23 0.245 482 +484 2 31.49 -50.91 47.05 0.245 483 +485 2 30.79 -51.58 46.89 0.245 484 +486 2 29.09 -54.96 46.31 0.245 485 +487 2 26.6 -55.06 45.63 0.245 486 +488 2 26.15 -55.8 45.48 0.245 487 +489 2 23.48 -56.48 44.79 0.18 488 +490 2 22.67 -60.14 44.43 0.18 489 +491 2 21.52 -62.43 44.03 0.18 490 +492 2 19.84 -62.29 42.6 0.18 491 +493 2 18.64 -63.93 42.16 0.18 492 +494 2 16.16 -64.02 41.49 0.18 493 +495 2 14.44 -64.49 41.01 0.18 494 +496 2 12.82 -66.13 41.7 0.18 495 +497 2 13.95 -69.41 41.88 0.18 496 +498 2 17.94 -71.09 43.01 0.18 497 +499 2 19.83 -71.28 47.65 0.245 498 +500 2 21.28 -72.83 50.79 0.245 499 +501 2 26.43 -75.83 54.04 0.245 500 +502 2 13.95 -73.35 44.12 0.18 497 +503 2 13.38 -76.59 43.85 0.18 502 +504 2 13.3 -78.59 43.75 0.18 503 +505 2 10.73 -80.03 41.76 0.18 504 +506 2 8.39 -82.2 41.0 0.18 505 +507 2 6.93 -84.76 40.45 0.18 506 +508 2 5.53 -84.69 37.85 0.18 507 +509 2 4.52 -85.44 34.75 0.18 508 +510 2 -0.05 -84.35 33.5 0.18 509 +511 2 0.09 -14.61 5.5 0.91 418 +512 2 0.03 -15.2 5.52 0.91 511 +513 2 -0.87 -17.28 5.19 0.91 512 +514 2 -1.12 -19.9 7.57 0.425 513 +515 2 -0.84 -22.03 9.9 0.425 514 +516 2 1.41 -23.89 10.54 0.425 515 +517 2 2.61 -28.26 16.72 0.425 516 +518 2 4.61 -30.17 18.33 0.425 517 +519 2 6.64 -31.85 19.02 0.365 518 +520 2 7.55 -32.06 21.85 0.365 519 +521 2 9.83 -33.86 24.0 0.365 520 +522 2 10.93 -36.97 25.07 0.365 521 +523 2 11.91 -39.15 28.21 0.305 522 +524 2 12.81 -40.29 30.43 0.305 523 +525 2 14.45 -42.1 32.0 0.245 524 +526 2 14.87 -43.66 34.59 0.245 525 +527 2 14.98 -46.61 34.56 0.245 526 +528 2 3.94 -24.14 15.15 0.305 516 +529 2 5.44 -24.24 18.87 0.305 528 +530 2 9.47 -21.24 20.18 0.305 529 +531 2 -1.42 -17.37 5.92 0.79 513 +532 2 -3.3 -18.89 7.28 0.79 531 +533 2 -3.95 -23.03 6.48 0.305 532 +534 2 -5.31 -26.89 5.97 0.305 533 +535 2 -9.89 -30.21 5.38 0.305 534 +536 2 -12.66 -32.25 1.4 0.305 535 +537 2 -15.23 -34.7 -1.76 0.305 536 +538 2 -18.09 -36.54 -5.19 0.305 537 +539 2 -19.73 -38.41 -5.71 0.305 538 +540 2 -21.59 -42.09 -5.57 0.245 539 +541 2 -24.66 -43.11 -5.61 0.245 540 +542 2 -26.88 -45.8 -6.46 0.18 541 +543 2 -29.6 -46.0 -7.83 0.18 542 +544 2 -31.38 -48.34 -8.39 0.18 543 +545 2 -34.29 -49.18 -10.35 0.18 544 +546 2 -38.54 -52.01 -11.61 0.18 545 +547 2 -40.83 -55.22 -13.33 0.18 546 +548 2 -25.9 -41.8 -9.37 0.18 541 +549 2 -29.98 -43.3 -12.65 0.18 548 +550 2 -33.39 -44.07 -16.19 0.18 549 +551 2 -40.62 -44.46 -21.16 0.18 550 +552 2 -44.36 -45.45 -24.13 0.18 551 +553 2 -46.27 -44.8 -26.07 0.18 552 +554 2 -50.33 -46.94 -29.27 0.18 553 +555 2 -54.88 -49.56 -32.67 0.18 554 +556 2 -56.13 -49.28 -33.05 0.18 555 +557 2 -58.53 -51.18 -33.72 0.18 556 +558 2 -4.52 -20.55 4.86 0.305 532 +559 2 -7.48 -23.15 3.97 0.305 558 +560 2 -11.11 -24.22 2.53 0.305 559 +561 2 -11.22 -26.78 0.8 0.305 560 +562 2 -12.98 -26.98 0.26 0.305 561 +563 2 -13.75 -26.23 0.08 0.305 562 +564 2 -15.44 -27.84 -0.42 0.305 563 +565 2 -18.83 -27.86 -5.07 0.305 564 +566 2 -22.56 -28.73 -7.98 0.245 565 +567 2 -24.68 -30.96 -8.63 0.245 566 +568 2 -26.5 -32.78 -11.42 0.245 567 +569 2 -27.98 -34.48 -12.87 0.12 568 +570 2 -30.06 -36.07 -14.89 0.18 569 +571 2 -34.31 -35.91 -15.51 0.18 570 +572 2 -37.01 -37.27 -17.9 0.18 571 +573 2 -40.81 -39.36 -19.99 0.18 572 +574 2 -43.75 -41.31 -21.17 0.18 573 +575 2 -48.22 -42.96 -24.2 0.18 574 +576 2 -52.06 -45.63 -27.83 0.18 575 +577 2 -56.58 -48.79 -30.98 0.18 576 +578 2 -59.33 -51.67 -35.56 0.18 577 +579 2 -59.82 -53.57 -36.54 0.18 578 +580 2 -62.93 -54.61 -37.47 0.18 579 +581 2 -64.97 -55.73 -38.06 0.18 580 +582 2 -66.32 -58.71 -38.54 0.18 581 +583 2 -70.75 -59.19 -39.75 0.18 582 +584 2 -70.04 -57.76 -41.74 0.18 583 +585 2 -71.98 -57.61 -42.67 0.18 584 +586 2 -72.62 -55.75 -45.0 0.18 585 +587 2 -74.46 -55.8 -47.63 0.12 586 +588 2 -77.56 -55.97 -49.51 0.12 587 +589 2 -80.73 -57.68 -51.0 0.12 588 +590 2 -83.96 -59.29 -53.18 0.12 589 +591 2 -73.6 -61.49 -40.19 0.18 583 +592 2 -77.01 -63.1 -44.18 0.18 591 +593 2 -28.19 -32.25 -11.86 0.18 568 +594 2 -29.36 -33.46 -13.88 0.18 593 +595 2 -31.08 -31.57 -16.04 0.18 594 +596 2 -31.22 -30.67 -17.96 0.18 595 +597 2 -33.26 -30.53 -18.5 0.18 596 +598 2 -34.38 -29.28 -18.76 0.18 597 +599 2 -36.24 -30.44 -20.6 0.18 598 +600 2 -37.13 -30.32 -21.56 0.18 599 +601 2 -38.31 -29.32 -21.85 0.18 600 +602 2 -40.2 -29.48 -22.36 0.12 601 +603 2 -40.42 -30.04 -25.76 0.12 602 diff --git a/tests/test_lineageTree.py b/tests/test_lineageTree.py index b8df55f..2056ffe 100644 --- a/tests/test_lineageTree.py +++ b/tests/test_lineageTree.py @@ -8,6 +8,7 @@ LineageTreeManager, read_from_mamut_xml, read_from_mastodon, + read_from_swc, tree_approximation, ) @@ -16,6 +17,12 @@ lt = LineageTree.load("tests/data/demo.lT") +def test_swc_reader(): + lT3 = read_from_swc("tests/data/204-2-6nj.CNG.swc") + assert len(lT3.nodes) == 603 + assert not lT3.temporal + + def test_read_MaMuT_xml(): assert lT1.name == "test-mamut" assert len(lT1.nodes) == 2430 @@ -25,6 +32,9 @@ def test_read_MaMuT_xml(): assert len(lT2.nodes) == 41 assert len(lT2.successor) == 41 assert len(lT2.find_leaves(40)) == 2 + assert lT2.temporal + assert lT1.temporal + assert lt.temporal @pytest.fixture(scope="session")