def conn():
    # Do not use ":memory:" ! SqlThread open the file
    tempdb = tempfile.mkstemp(suffix=".db")[1]
    conn = sql.get_sql_connection(tempdb)
    importer.import_reader(
        conn, VcfReader(open("examples/test.snpeff.vcf"), "snpeff"))
    return conn
Esempio n. 2
0
def test_import_pedfile():
    """Test import of samples from .tfam PED file"""
    reader = VcfReader(open("examples/test.snpeff.vcf"), "snpeff")
    conn = sqlite3.connect(":memory:")
    import_reader(conn, reader)
    import_pedfile(conn, "examples/test.snpeff.pedigree.tfam")

    samples = [dict(row) for row in conn.execute("SELECT * FROM samples")]
    print("Found samples:", samples)

    expected_first_sample = {
        "id": 1,
        "name": "NORMAL",
        "family_id": "fam",
        "father_id": 2,
        "mother_id": 1,
        "sex": 2,
        "phenotype": 1,
    }
    expected_second_sample = {
        "id": 2,
        "name": "TUMOR",
        "family_id": "fam",
        "father_id": 0,
        "mother_id": 0,
        "sex": 1,
        "phenotype": 2,
    }

    # Third sample is not conform
    assert len(samples) == 2

    assert expected_first_sample in samples
    assert expected_second_sample in samples
Esempio n. 3
0
def conn():

    #  Required a real file to make it work !
    tempdb = tempfile.mkstemp(suffix=".db")[1]
    conn = sql.get_sql_connection(tempdb)
    importer.import_reader(
        conn, VcfReader(open("examples/test.snpeff.vcf"), "snpeff"))
    return conn
Esempio n. 4
0
def conn():
    conn = sql.get_sql_connection(":memory:")
    import_reader(conn, VcfReader(open("examples/test.snpeff.vcf"), "snpeff"))
    return conn
Esempio n. 5
0
    def on_fields_changed(self):

        if self.mainwindow is None or self._is_refreshing:
            return

        self.mainwindow.state.fields = self.model.fields
        self.mainwindow.refresh_plugins(sender=self)


if __name__ == "__main__":
    import sys
    from cutevariant.core.importer import import_reader
    from cutevariant.core.reader import FakeReader

    app = QApplication(sys.argv)

    conn = sql.get_sql_connection(":memory:")
    import_reader(conn, FakeReader())
    # import_file(conn, "examples/test.snpeff.vcf")

    view = FieldsEditorWidget()

    view.conn = conn
    view.fields = ["chr", "pos"]

    # view.changed.connect(lambda : print(view.columns))

    view.show()

    app.exec_()
Esempio n. 6
0
def test_import(reader):
    conn = sqlite3.connect(":memory:")
    import_reader(conn, reader)