<commit_before>#!/usr/bin/env python

from sqlalchemy import Column, Integer, String, Float, Enum, ForeignKey
from sqlalchemy.orm import relationship
from base import Base


class Mutation(Base):
    """Base class for all mutations"""
    __tablename__ = "mutation"

    id = Column(Integer, primary_key=True)
    library_id = Column(Integer, ForeignKey("library.id"))
    mutation_type = Column(String(50))
    status = Column(Enum("somatic", "germline", "artifact", "unknown"))

    __mapper_args__ = {"polymorphic_on": mutation_type}

    library = relationship("Library", backref="mutations")


class SingleNucleotideVariant(Mutation):
    """Model for single nucleotide variants
    (i.e. involving one genomic position)
    """
    __tablename__ = "snv"

    id = Column(Integer, ForeignKey("mutation.id"), primary_key=True)
    chrom = Column(String(length=50))
    pos = Column(Integer)
    ref_allele = Column(String(length=1))
    alt_allele = Column(String(length=1))
    ref_count = Column(Integer)
    alt_count = Column(Integer)


class StructuralVariation(Mutation):
    """Model for structural variations"""
    __tablename__ = "sv"

    id = Column(Integer, ForeignKey("mutation.id"), primary_key=True)
    chrom1 = Column(String(length=50))
    pos1 = Column(Integer)
    strand1 = Column(String(length=1))
    chrom2 = Column(String(length=50))
    pos2 = Column(Integer)
    strand2 = Column(String(length=1))
    sv_type = Column(Enum("translocation", "inversion", "insertion", "deletion", "duplication"))


class CopyNumberVariation(Mutation):
    """Model for copy number variations as called by
    callers which provide a fold-change
    (e.g. like tools which use read depth)
    """
    __tablename__ = "cnv"

    id = Column(Integer, ForeignKey("mutation.id"), primary_key=True)
    chrom = Column(String(length=50))
    start_pos = Column(Integer)
    end_pos = Column(Integer)
    size = Column(Integer)
    fold_change = Column(Float)
    copy_state = Column(Integer)
<commit_msg>added relationships between mutations<commit_after>#!/usr/bin/env python

from sqlalchemy import Column, Integer, String, Float, Enum, ForeignKey
from sqlalchemy.orm import relationship
from base import Base


class Mutation(Base):
    """Base class for all mutations"""
    __tablename__ = "mutation"

    id = Column(Integer, primary_key=True)
    library_id = Column(Integer, ForeignKey("library.id"))
    mutation_type = Column(String(50))
    status = Column(Enum("somatic", "germline", "artifact", "unknown"))

    __mapper_args__ = {"polymorphic_on": mutation_type}

    library = relationship("Library", backref="mutations")


class SingleNucleotideVariant(Mutation):
    """Model for single nucleotide variants
    (i.e. involving one genomic position)
    """
    __tablename__ = "snv"

    id = Column(Integer, ForeignKey("mutation.id"), primary_key=True)
    chrom = Column(String(length=50))
    pos = Column(Integer)
    ref_allele = Column(String(length=1))
    alt_allele = Column(String(length=1))
    ref_count = Column(Integer)
    alt_count = Column(Integer)

    mutation = relationship("Mutation", backref="snv")


class StructuralVariation(Mutation):
    """Model for structural variations"""
    __tablename__ = "sv"

    id = Column(Integer, ForeignKey("mutation.id"), primary_key=True)
    chrom1 = Column(String(length=50))
    pos1 = Column(Integer)
    strand1 = Column(String(length=1))
    chrom2 = Column(String(length=50))
    pos2 = Column(Integer)
    strand2 = Column(String(length=1))
    sv_type = Column(Enum("translocation", "inversion", "insertion", "deletion", "duplication"))

    mutation = relationship("Mutation", backref="sv")


class CopyNumberVariation(Mutation):
    """Model for copy number variations as called by
    callers which provide a fold-change
    (e.g. like tools which use read depth)
    """
    __tablename__ = "cnv"

    id = Column(Integer, ForeignKey("mutation.id"), primary_key=True)
    chrom = Column(String(length=50))
    start_pos = Column(Integer)
    end_pos = Column(Integer)
    size = Column(Integer)
    fold_change = Column(Float)
    copy_state = Column(Integer)

    mutation = relationship("Mutation", backref="cnv")

{'fraction_non_alphanumeric': 0.12556373130785664, 'fraction_numerical': 0.009494422027059102, 'mean_word_length': 4.423423423423423, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6849533', 'n_tokens_mistral': 1341, 'n_tokens_neox': 1270, 'n_words': 306}