@@ -92,15 +92,26 @@ class ColumnarVariantCallProcessor : public GenomicsDBVariantCallProcessor {
92
92
const int64_t * coordinates,
93
93
const genomic_interval_t & genomic_interval,
94
94
const std::vector<genomic_field_t >& genomic_fields);
95
+ void process_str_field (const std::string& field_name, PyObject *calls, int dims, npy_intp *sizes) {
96
+ auto found = std::find (m_field_names.begin (), m_field_names.end (), field_name);
97
+ if (found != m_field_names.end ()) {
98
+ PyDict_SetItem (calls, PyUnicode_FromString (field_name.c_str ()),
99
+ PyArray_SimpleNewFromData (dims, sizes, NPY_OBJECT, m_string_fields[field_name].data ()));
100
+ }
101
+ }
95
102
PyObject* construct_data_frame () {
96
103
int dims = 1 ;
97
104
npy_intp sizes[1 ] = { static_cast <npy_intp>(m_sample_names.size ()) };
98
105
PyObject *calls = PyDict_New ();
99
106
PyDict_SetItem (calls, PyUnicode_FromString (" Sample" ), PyArray_SimpleNewFromData (dims, sizes, NPY_OBJECT, m_sample_names.data ()));
100
107
PyDict_SetItem (calls, PyUnicode_FromString (" CHR" ), PyArray_SimpleNewFromData (dims, sizes, NPY_OBJECT, m_chrom.data ()));
101
108
PyDict_SetItem (calls, PyUnicode_FromString (" POS" ), PyArray_SimpleNewFromData (dims, sizes, NPY_INT64, m_pos.data ()));
102
-
109
+ // Process REF, ALT and GT first.
110
+ process_str_field (" REF" , calls, dims, sizes);
111
+ process_str_field (" ALT" , calls, dims, sizes);
112
+ process_str_field (" GT" , calls, dims, sizes);
103
113
for (auto field_name: m_field_names) {
114
+ if (field_name == " REF" || field_name == " ALT" || field_name == " GT" ) continue ;
104
115
if (m_string_fields.find (field_name) != m_string_fields.end ()) {
105
116
PyDict_SetItem (calls, PyUnicode_FromString (field_name.c_str ()),
106
117
PyArray_SimpleNewFromData (dims, sizes, NPY_OBJECT, m_string_fields[field_name].data ()));
0 commit comments