Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_repeated_id():
_test_swc_exception('''# A simple neuron with a repeated id
1 1 0 0 1 0.5 -1
2 3 0 0 2 0.5 1
3 3 0 0 3 0.5 2
4 3 0 0 4 0.5 3
4 3 0 0 4 0.5 3 # <-- repeated id
5 3 0 0 5 0.5 4
''',
RawDataError,
'Repeated ID: 4\nID already appears here:',
':6:warning')
from nose.tools import ok_, nottest
import subprocess
from morphio import Morphology, SomaError, RawDataError, MorphioError
from morphio.mut import Morphology as MutMorphology
bad_files = {'MorphologyRepository/Vincent Delattre/vd100714C/vd100714C_idA.ASC': SomaError,
'MorphologyRepository/Vincent Delattre/vd100714B/vd100714B_idB.ASC': RawDataError,
'MorphologyRepository/Shruti Muralidhar/sm100614a2/sm100614a2.ASC': RawDataError,
'MorphologyRepository/Rodrigo Perin/rp120607_P_1-2/rp120607_P_1-2_idE.ASC': SomaError,
'MorphologyRepository/Shruti Muralidhar/sm080904a1-6/._sm080904a1.asc': SomaError,
'MorphologyRepository/Rodrigo Perin/rp110616_C1/rp110616_C1_idB.ASC': SomaError,
'MorphologyRepository/Thomas Berger/tkb070202a2/tkb070202a2_ch0_cc2_n_tb_100x_3.asc': RawDataError,
'MorphologyRepository/Thomas Berger/tkb061122a2/tkb061122a2_ch1_ct_n_rm_100x_1.asc': RawDataError,
'MorphologyRepository/Thomas Berger/tkb051201b1/tkb051201b1_ch7_ct_n_es_100x_1.asc': RawDataError,
'MorphologyRepository/Thomas Berger/tkb060123a2/tkb060123a2_ch2_ct_x_db_60x_2.asc': RawDataError,
'MorphologyRepository/Cristina Radaelli/cr161021_A/cr161021_A_idB.ASC': RawDataError,
'MorphologyRepository/Cristina Radaelli/cr161027_A/cr161027_A_idA.ASC': SomaError,
'MorphologyRepository/Olivier Gschwend/og060829a1-4/og060829a1-4_idB.asc': RawDataError,
'MorphologyRepository/Ani Gupta/C271097A/C271097A-I4.asc': RawDataError,
'MorphologyRepository/Ani Gupta/C030397A/C030397A-P3.asc': RawDataError,
'MorphologyRepository/Ani Gupta/C310897B/C310897B-P3.asc': RawDataError,
def test_unfinished_file():
_test_asc_exception('''
((Dendrite)
(3 -4 0 2)
(3 -6 0 2)
(3 -8 0 2)
(3 -10 0 2)
(
(3 -10 0 2)
(0 -10 0 2)
(-3 -10 0 2)
|
''',
RawDataError,
"Hit end of file while consuming a neurite",
":12:error")
def test_cyclic():
_test_swc_exception("""1 1 0 0 0 1. -1
2 3 0 0 0 1. 1
3 3 0 5 0 1. 2
4 3 -5 5 0 0. 3
5 3 6 5 0 0. 3
6 2 0 0 0 1. 6 # <-- cyclic point
7 2 0 -4 0 1. 6
8 2 6 -4 0 0. 7
9 2 -5 -4 0 0. 7""",
RawDataError,
'Parent ID can not be itself',
':6:error')
def test_wrong_section_type():
assert_raises(RawDataError, Morphology, os.path.join(H5V1_PATH, 'simple-broken-section-type.h5'))
def test_unknown_token():
_test_asc_exception('''
("CellBody"
(Color Red)
(CellBody)
(1 1 0 1 S1)
(Z 1 0 1 S2) ; <-- Z is a BAD token
(-1 -1 0 2 S3)
)''',
RawDataError,
"Unexpected token: Z",
":6:error")