complex_model/GulcalcToBin.py
def gulcalc_sqlite_to_bin(con, output, add_first_separator):
    """This transforms a sqlite result table (rf format) into oasis loss binary stream

    :param con: sqlite connection to result batch
    :param output: output stream where results will be written to
    :param add_first_separator: boolean flag to add separator 0/0 for second, third, ... batches
    :return: OASIS compliant item or coverage binary stream
    """
    cur = con.cursor()
    cur.execute("SELECT event_id, loc_id, sample_id, loss FROM oasis_loss ORDER BY event_id, loc_id, sample_id")

    last_key = (0, 0)
    rc = 0
    for row in cursor_iterator(cur):
        current_key = (int(row[0]), int(row[1]))
        if not last_key == current_key:
            if not last_key == (0, 0) or add_first_separator:
                output.write(struct.pack('Q', 0))  # sidx/loss 0/0 as separator
            output.write(struct.pack('II', current_key[0], current_key[1]))
            last_key = (int(row[0]), int(row[1]))
        output.write(struct.pack('if', int(row[2]), float(row[3])))
        rc = rc + 1
    return rc
This transforms a sqlite result table (rf format) into oasis loss binary stream

    :param con: sqlite connection to result batch
    :param output: output stream where results will be written to
    :param add_first_separator: boolean flag to add separator 0/0 for second, third, ... batches
    :return: OASIS compliant item or coverage binary stream
    
This transforms a sqlite result table (rf format) into oasis loss binary stream
This transforms a sqlite result table ( rf format ) into oasis loss binary stream
def gulcalc_sqlite_to_bin(con, output, add_first_separator):
    cur = con.cursor()
    cur.execute("SELECT event_id, loc_id, sample_id, loss FROM oasis_loss ORDER BY event_id, loc_id, sample_id")
    last_key = (0, 0)
    rc = 0
    for row in cursor_iterator(cur):
        current_key = (int(row[0]), int(row[1]))
        if not last_key == current_key:
            if not last_key == (0, 0) or add_first_separator:
                output.write(struct.pack('Q', 0))  
            output.write(struct.pack('II', current_key[0], current_key[1]))
            last_key = (int(row[0]), int(row[1]))
        output.write(struct.pack('if', int(row[2]), float(row[3])))
        rc = rc + 1
    return rc
def gulcalc_sqlite_to_bin ( con , output , add_first_separator ) : cur = con . cursor ( ) cur . execute ( "SELECT event_id, loc_id, sample_id, loss FROM oasis_loss ORDER BY event_id, loc_id, sample_id" ) last_key = ( 0 , 0 ) rc = 0 for row in cursor_iterator ( cur ) : current_key = ( int ( row [ 0 ] ) , int ( row [ 1 ] ) ) if not last_key == current_key : if not last_key == ( 0 , 0 ) or add_first_separator : output . write ( struct . pack ( 'Q' , 0 ) ) output . write ( struct . pack ( 'II' , current_key [ 0 ] , current_key [ 1 ] ) ) last_key = ( int ( row [ 0 ] ) , int ( row [ 1 ] ) ) output . write ( struct . pack ( 'if' , int ( row [ 2 ] ) , float ( row [ 3 ] ) ) ) rc = rc + 1 return rc
This transforms a sqlite result table (rf format) into oasis loss binary stream
This transforms a sqlite result table ( rf format ) into oasis loss binary stream
"""This transforms a sqlite result table (rf format) into oasis loss binary stream

    :param con: sqlite connection to result batch
    :param output: output stream where results will be written to
    :param add_first_separator: boolean flag to add separator 0/0 for second, third, ... batches
    :return: OASIS compliant item or coverage binary stream
    """ # sidx/loss 0/0 as separator
OASIS compliant item or coverage binary stream
OASIS compliant item or coverage binary stream
con
sqlite connection to result batch
sqlite connection to result batch
output
output stream where results will be written to
output stream where results will be written to
add_first_separator
boolean flag to add separator 0/0 for second, third, ... batches
boolean flag to add separator 0 / 0 for second third ... batches