...
 
Commits (3)
......@@ -57,7 +57,7 @@ insertion_dict(mutalyzer::Variant const &variant)
PyErr_SetString(PyExc_MemoryError, "Could not allocate memory for Py_BuildValue");
return NULL;
} // if
return Py_BuildValue("{s:s,s:s,s:O}", "inverted", "true", "source", "reference", "location", range);
return Py_BuildValue("{s:b,s:s,s:O}", "inverted", true, "source", "reference", "location", range);
} // if
PyObject const* const range = range_location(variant.sample_start, variant.sample_end);
......@@ -106,26 +106,30 @@ variant_dict(std::vector<mutalyzer::Variant>::const_iterator &it)
PyErr_SetString(PyExc_MemoryError, "Could not allocate memory for PyList_Append");
return NULL;
} // if
while ((it->type & mutalyzer::TRANSPOSITION_CLOSE) != mutalyzer::TRANSPOSITION_CLOSE)
if ((it->type & mutalyzer::TRANSPOSITION_CLOSE) != mutalyzer::TRANSPOSITION_CLOSE)
{
PyObject const* const item = insertion_dict(*it);
if (item == NULL)
{
Py_DECREF(range);
Py_DECREF(inserted);
PyErr_SetString(PyExc_MemoryError, "Could not allocate memory for Py_BuildValue");
return NULL;
} // if
if (PyList_Append(inserted, const_cast<PyObject*>(item)) != 0)
do
{
Py_DECREF(range);
Py_DECREF(inserted);
Py_DECREF(item);
PyErr_SetString(PyExc_MemoryError, "Could not allocate memory for PyList_Append");
return NULL;
} // if
++it;
} // while
++it;
PyObject const* const item = insertion_dict(*it);
if (item == NULL)
{
Py_DECREF(range);
Py_DECREF(inserted);
PyErr_SetString(PyExc_MemoryError, "Could not allocate memory for Py_BuildValue");
return NULL;
} // if
if (PyList_Append(inserted, const_cast<PyObject*>(item)) != 0)
{
Py_DECREF(range);
Py_DECREF(inserted);
Py_DECREF(item);
PyErr_SetString(PyExc_MemoryError, "Could not allocate memory for PyList_Append");
return NULL;
} // if
} while ((it->type & mutalyzer::TRANSPOSITION_CLOSE) != mutalyzer::TRANSPOSITION_CLOSE);
} // if
} // if
else if (it->type == mutalyzer::IDENTITY)
{
......
......@@ -6,6 +6,11 @@ REFERENCE = 'ACGTCGATTCGCTAGCTTCGGGGGATAGATAGAGATATAGAGAT'
TESTS = [
# Empty input
('',
'',
[]),
# No variants
(REFERENCE,
REFERENCE,
......@@ -171,7 +176,7 @@ TESTS = [
## Deletion/insertion 21_23delinsTTTT
(REFERENCE,
'ACGTCGATTCGCTAGCTTCGTTTTGATAGATAGAGATATAGAGAT',
[{'location': {'start': {'position': 0, 'type': 'point'},
[{'location': {'start': {'position': 0, 'type': 'point'},
'end': {'position': 20, 'type': 'point'},
'type': 'range'},
'type': 'equal'},
......@@ -259,7 +264,7 @@ TESTS = [
'end': {'position': 7, 'type': 'point'},
'type': 'range'},
'insertions': [{'source': 'observed',
'location': {'start': {'position': 7, 'type': 'point'},
'location': {'start': {'position': 7, 'type': 'point'},
'end' : {'position': 10, 'type': 'point'},
'type': 'range'}}],
'type': 'delins'},
......@@ -330,7 +335,7 @@ TESTS = [
## [26A>C;30C>A;35G>C]
('TAAGCACCAGGAGTCCATGAAGAAGATGGCTCCTGCCATGGAATCCCCTACTCTACTGTG',
'TAAGCACCAGGAGTCCATGAAGAAGCTGGATCCTCCCATGGAATCCCCTACTCTACTGTG',
[{'location': {'start': {'position': 0, 'type': 'point'},
[{'location': {'start': {'position': 0, 'type': 'point'},
'end': {'position': 25, 'type': 'point'},
'type': 'range'},
'type': 'equal'},
......@@ -374,7 +379,7 @@ TESTS = [
## [26_29inv;30C>G]
('TAAGCACCAGGAGTCCATGAAGAAGATGGCTCCTGCCATGGAATCCCCTACTCTA',
'TAAGCACCAGGAGTCCATGAAGAAGCCATGTCCTGCCATGGAATCCCCTACTCTA',
[{'location': {'start': {'position': 0, 'type': 'point'},
[{'location': {'start': {'position': 0, 'type': 'point'},
'end': {'position': 25, 'type': 'point'},
'type': 'range'},
'type': 'equal'},
......@@ -398,7 +403,7 @@ TESTS = [
## [26_29inv;30C>G;41del]
('TAAGCACCAGGAGTCCATGAAGAAGATGGCTCCTGCCATGGAATCCCCTACTCTA',
'TAAGCACCAGGAGTCCATGAAGAAGCCATGTCCTGCCATGAATCCCCTACTCTA',
[{'location': {'start': {'position': 0, 'type': 'point'},
[{'location': {'start': {'position': 0, 'type': 'point'},
'end': {'position': 25, 'type': 'point'},
'type': 'range'},
'type': 'equal'},
......@@ -433,10 +438,51 @@ TESTS = [
# Transpositions
## Duplication 17_43dup?
## Transpostion 37_38ins15_24
('ATGGCGGCGGTGGTCGCCCTCTCCTTGAGGCGCCGGTTGCCGGCCACAACCCTTGGCGGA',
'ATGGCGGCGGTGGTCGCCCTCTCCTTGAGGCGCCGGTCGCCCTCTCCTGCCGGCCACAACCCTTGGCGGA',
[{'location': {'start': {'position': 0, 'type': 'point'},
'end': {'position': 37, 'type': 'point'},
'type': 'range'},
'type': 'equal'},
{'location': {'start': {'position': 37, 'type': 'point'},
'end': {'position': 37, 'type': 'point'},
'type': 'range'},
'insertions': [{'source': 'reference',
'location': {'start': {'position': 14, 'type': 'point'},
'end' : {'position': 24, 'type': 'point'},
'type': 'range'}}],
'type': 'delins'},
{'location': {'start': {'position': 37, 'type': 'point'},
'end': {'position': 60, 'type': 'point'},
'type': 'range'},
'type': 'equal'}]),
## Transposition of reverse complement 37_38ins3_26inv
('ATGGCGGCGGTGGTCGCCCTCTCCTTGAGGCGCCGGTTGCCGGCCACAACCCTTGGCGGA',
'ATGGCGGCGGTGGTCGCCCTCTCCTTGAGGCGCCGGTAAGGAGAGGGCGACCACCGCCGCCTGCCGGCCACAACCCTTGGCGGA',
[{'location': {'start': {'position': 0, 'type': 'point'},
'end': {'position': 37, 'type': 'point'},
'type': 'range'},
'type': 'equal'},
{'location': {'start': {'position': 37, 'type': 'point'},
'end': {'position': 37, 'type': 'point'},
'type': 'range'},
'insertions': [{'source': 'reference',
'inverted': True,
'location': {'start': {'position': 2, 'type': 'point'},
'end' : {'position': 26, 'type': 'point'},
'type': 'range'}}],
'type': 'delins'},
{'location': {'start': {'position': 37, 'type': 'point'},
'end': {'position': 60, 'type': 'point'},
'type': 'range'},
'type': 'equal'}]),
## Duplication 18_42dup
('ATGGCGGCGGTGGTCGCCCTCTCCTTGAGGCGCCGGTTGCCGGCCACAACCCTTGGCGGA',
'ATGGCGGCGGTGGTCGCCCTCTCCTTGAGGCGCCGGTTGCCGCCTCTCCTTGAGGCGCCGGTTGCCGGCCACAACCCTTGGCGGA',
[{'location': {'start': {'position': 0, 'type': 'point'},
[{'location': {'start': {'position': 0, 'type': 'point'},
'end': {'position': 42, 'type': 'point'},
'type': 'range'},
'type': 'equal'},
......@@ -453,6 +499,32 @@ TESTS = [
'type': 'range'},
'type': 'equal'}]),
# Compound transpositions
# 42_43ins[CA;19_42]
('ATGGCGGCGGTGGTCGCCCTCTCCTTGAGGCGCCGGTTGCCGGCCACAACCCTTGGCGGA',
'ATGGCGGCGGTGGTCGCCCTCTCCTTGAGGCGCCGGTTGCCGCACTCTCCTTGAGGCGCCGGTTGCCGGCCACAACCCTTGGCGGA',
[{'location': {'start': {'position': 0, 'type': 'point'},
'end': {'position': 42, 'type': 'point'},
'type': 'range'},
'type': 'equal'},
{'location': {'start': {'position': 42, 'type': 'point'},
'end': {'position': 42, 'type': 'point'},
'type': 'range'},
'insertions': [{'source': 'observed',
'location': {'start': {'position': 42, 'type': 'point'},
'end' : {'position': 44, 'type': 'point'},
'type': 'range'}},
{'source': 'reference',
'location': {'start': {'position': 18, 'type': 'point'},
'end' : {'position': 42, 'type': 'point'},
'type': 'range'}}],
'type': 'delins'},
{'location': {'start': {'position': 42, 'type': 'point'},
'end': {'position': 60, 'type': 'point'},
'type': 'range'},
'type': 'equal'}]),
]
......