Example #1
0
class BaseModel(db.Model):
    __abstract__ = True

    created_on = db.Column('CREATED_ON',
                           db.TIMESTAMP,
                           default=db.func.now(),
                           nullable=False)
    updated_on = db.Column('UPDATED_ON',
                           db.TIMESTAMP,
                           default=db.func.now(),
                           onupdate=db.func.now(),
                           nullable=False)

    @declared_attr
    def created_by(cls):
        return db.Column('CREATED_BY',
                         db.String(50),
                         db.ForeignKey('USER_ROLE.USERNAME'),
                         default='system',
                         nullable=False)

    @declared_attr
    def updated_by(cls):
        return db.Column('UPDATED_BY',
                         db.String(50),
                         db.ForeignKey('USER_ROLE.USERNAME'),
                         default='system',
                         nullable=False)
class ObservedMapComment(BaseModel):
    __tablename__ = 'OBSERVED_MAP_COMMENT'
    id = db.Column('ID', INTEGER(unsigned=True), primary_key=True, unique=True)
    comment = db.Column('COMMENT', db.String(1000), nullable=True)

    observed_map_id = db.Column('OBSERVED_MAP_ID', INTEGER(unsigned=True),
                                db.ForeignKey('OBSERVED_MAP.ID', ondelete='CASCADE', post_update=True))

    def __init__(self, comment, observed_map_id, created_by, updated_by):
        self.comment = comment
        self.observed_map_id = observed_map_id
        self.created_by = created_by
        self.updated_by = updated_by

    def __repr__(self):
        return (
            "<id {}, comment {}>").format(
            self.id,
            self.comment)

    def as_dict(self):
        return {
            "id": self.id,
            "comment": self.comment,
            "observed_map_id": self.observed_map_id,
            "created_by": self.created_by,
            "updated_by": self.updated_by,
            "created_on": self.created_on
        }
Example #3
0
class AnalysisComment(BaseModel):
    __tablename__ = 'ANALYSIS_COMMENT'
    id = db.Column('ID', INTEGER(unsigned=True), primary_key=True, unique=True)
    comment = db.Column('COMMENT', db.String(1000), nullable=True)

    analysis_id = db.Column('ANALYSIS_ID', INTEGER(unsigned=True),
                            db.ForeignKey('ANALYSIS.ID'))

    def __init__(self, comment, analysis_id, created_by, updated_by):
        self.comment = comment
        self.analysis_id = analysis_id
        self.created_by = created_by
        self.updated_by = updated_by

    def __repr__(self):
        return (
            "<id {}, comment {}>").format(
            self.id,
            self.comment)

    def as_dict(self):
        return {
            "id": self.id,
            "comment": self.comment,
            "analysis_id": self.analysis_id,
            "created_on": self.created_on,
            "created_by": self.created_by
        }
Example #4
0
class UserRole(BaseModel):
    __tablename__ = 'USER_ROLE'
    user_name = db.Column('USERNAME',
                          db.String(50),
                          primary_key=True,
                          unique=True)
    role = db.Column('ROLE', db.Enum(UserRole), nullable=False)
    active = db.Column('ACTIVE', db.Boolean, default=True, nullable=False)

    def __init__(self, user_name, role, active):
        self.user_name = user_name
        self.role = role
        self.active = active

    def __repr__(self):
        return ("<UserName {},Role {}, Active {}," +
                "CreatedOn {}, UpdatedOn {}, CreatedBy {}, " +
                "UpdatedBy {}>").format(self.user_name, self.role, self.active,
                                        self.created_on, self.updated_on,
                                        self.created_by, self.updated_by)

    def as_dict(self):
        return {
            'user_name': self.user_name,
            'role': self.role.value,
            'active': self.active
        }
class PipelineConfiguration(BaseModel):
    __tablename__ = 'PIPELINE_CONFIGURATION'
    id = db.Column('ID', INTEGER(unsigned=True), primary_key=True,
                   unique=True)
    name = db.Column('NAME', db.String(100), nullable=False)
    endogenous_set = db.Column('ENDOGENOUS_SET', db.String(500), nullable=False)
    version = db.Column('VERSION', INTEGER(unsigned=True), nullable=False)
    conf_file = db.Column('CONF_FILE', db.Text, nullable=True)

    analysis_config = db.relationship('Analysis', backref='pipeline_config', lazy='dynamic')

    def __init__(self, name, version, conf_file, endogenous_set):
        self.name = name
        self.version = version
        self.conf_file = conf_file
        self.endogenous_set = endogenous_set

    def __repr__(self):
        return (
            "<id {}, name {}, version {}>").format(
            self.id,
            self.name,
            self.version
        )

    def as_dict(self):
        return {
            "id": self.id,
            "name": self.name,
            "endogenous_set": self.endogenous_set,
            "version": self.version,
            "conf_file": self.conf_file,
            "created_on": self.created_on
        }
class EndogenousJunction(BaseModel):
    __tablename__ = 'ENDOGENOUS_JUNCTION'
    id = db.Column('ID', INTEGER(unsigned=True), primary_key=True, unique=True)
    junction_set = db.Column('JUNCTION_SET', INTEGER(unsigned=True),
                             db.ForeignKey(EndogenousJunctionSet.id))
    junction_id = db.Column('JUNCTION_ID', INTEGER(unsigned=True),
                            db.ForeignKey(Junction.id))

    def __init__(self, junction_set, junction_id):
        self.junction_set = junction_set
        self.junction_id = junction_id

    def __repr__(self):
        return (
            "<id {}, junction_set {}>").format(
            self.id,
            self.junction_set
        )

    def as_dict(self):
        return {
            "id": self.id,
            "junction_id": self.junction_id,
            "junction_set": self.junction_set
        }
Example #7
0
class Map(BaseModel):
    __tablename__ = 'MAP'
    id = db.Column('ID', INTEGER(unsigned=True), primary_key=True, unique=True)
    construct_id = db.Column('CONSTRUCT_ID', db.String(50), nullable=True)
    pipeline_detail = db.Column('PIPELINE_DETAIL', db.Text, nullable=True)
    custom_pipeline_detail = db.Column('CUSTOM_PIPELINE_DETAIL',
                                       db.Text,
                                       nullable=True)
    map_analysis = db.relationship('MapAnalysis',
                                   backref='maps_map_analysis',
                                   lazy='dynamic')
    map_observed = db.relationship('ObservedMap',
                                   backref='maps_observed_map',
                                   lazy='dynamic')
    obs_map_version = 1

    def __init__(self,
                 construct_id,
                 pipeline_detail=None,
                 custom_pipeline_details=None):
        self.construct_id = construct_id
        self.pipeline_detail = pipeline_detail
        self.custom_pipeline_detail = custom_pipeline_details

    def __repr__(self):
        return ("<id {}, construct_id {}>").format(self.id, self.construct_id)

    def as_dict(self):
        return {
            "id": self.id,
            "construct_id": self.construct_id,
            "pipeline_detail": self.pipeline_detail,
            "custom_pipeline_detail": self.custom_pipeline_detail
        }
Example #8
0
class MapAnalysis(BaseModel):
    __tablename__ = 'MAP_ANALYSIS'
    id = db.Column('ID', INTEGER(unsigned=True), primary_key=True, unique=True)
    read_count = db.Column('READ_COUNT', db.String(50), nullable=True)

    analysis_id = db.Column('ANALYSIS_ID', INTEGER(unsigned=True),
                            db.ForeignKey('ANALYSIS.ID'))
    map_id = db.Column('MAP_ID', INTEGER(unsigned=True),
                       db.ForeignKey('MAP.ID'))

    variation = db.relationship('Variation',
                                backref='vars_mapanalysis',
                                lazy='dynamic')
    map_analysis_junctions = db.relationship('MapAnalysisJunctions',
                                             backref='junctions_mapanalysis',
                                             lazy='dynamic')

    def __init__(self, read_count, analysis_id, map_id):
        self.read_count = read_count
        self.analysis_id = analysis_id
        self.map_id = map_id

    def __repr__(self):
        return ("<id {}, read_count {}>").format(self.id, self.read_count)

    def as_dict(self):
        return {
            "id": self.id,
            "error": self.read_count,
            "analysis_id": self.analysis_id,
            "map_id": self.map_id
        }
Example #9
0
class EndogenousJunctionSet(BaseModel):
    __tablename__ = 'ENDOGENOUS_JUNCTION_SET'
    id = db.Column('ID', INTEGER(unsigned=True), primary_key=True, unique=True)
    crop_id = db.Column('CROP_ID', INTEGER(unsigned=True),
                        db.ForeignKey('CROP.ID'))
    name = db.Column('NAME', db.String(500), nullable=True)

    endogenous_junctions = db.relationship('EndogenousJunction',
                                           backref='endogenous_junction_set',
                                           lazy='dynamic')

    def __init__(self, crop_id, name):
        self.crop_id = crop_id
        self.name = name

    def __repr__(self):
        return (
            "<id {}, name {}, crop_id {}>").format(
            self.id,
            self.name,
            self.crop_id
        )

    def as_dict(self):
        return {
            "id": self.id,
            "crop_id": self.crop_id,
            "name": self.name
        }
Example #10
0
class TxMethod(BaseModel):
    __tablename__ = 'TX_METHOD'
    id = db.Column('ID', INTEGER(unsigned=True), primary_key=True, unique=True)
    method_name = db.Column('METHOD_NAME', db.String(50), nullable=True)

    request_id = db.relationship('Request', backref='txmethod', lazy='dynamic')

    def __init__(self, method_name):
        self.method_name = method_name

    def __repr__(self):
        return ("<id {}, method_name {}>").format(self.id, self.method_name)

    def as_dict(self):
        return {"id": self.id, "method_name": self.method_name}
Example #11
0
class FlatQFileForReads(BaseModel):
    __tablename__ = 'FLAT_Q_FILE_FOR_READS'
    id = db.Column('ID', INTEGER(unsigned=True), primary_key=True, unique=True)
    location = db.Column('LOCATION', db.String(50), nullable=True)

    #sample = db.relationship('Sample', uselist=False, backref='sample')

    def __init__(self, location):
        self.location = location

    def __repr__(self):
        return ("<id {}, location {}>").format(self.id, self.location)

    def as_dict(self):
        return {"id": self.id, "location": self.location}
Example #12
0
class Crop(BaseModel):
    __tablename__ = 'CROP'
    id = db.Column('ID', INTEGER(unsigned=True), primary_key=True, unique=True)
    organism = db.Column('ORGANISM', db.String(20), nullable=True)

    request_id = db.relationship('Request', backref='crop', lazy='dynamic')

    #endogenousJunctionSet = db.relationship('EndogenousJunctionSet', backref='endogenousJunctionSet', lazy='dynamic')

    def __init__(self, organism):
        self.organism = organism

    def __repr__(self):
        return ("<id {}, organism {}>").format(self.id, self.organism)

    def as_dict(self):
        return {"id": self.id, "organism": self.organism}
Example #13
0
class AnalysisTools(BaseModel):
    __tablename__ = 'ANALYSIS_TOOLS'
    id = db.Column('ID', INTEGER(unsigned=True), primary_key=True, unique=True)
    name = db.Column('NAME', db.String(100), nullable=False)

    analysis_tools_details = db.relationship(
        'AnalysisToolsDetails',
        backref='tools_details_analysis_tools',
        lazy='dynamic')

    def __init__(self, name):
        self.name = name

    def __repr__(self):
        return ("<id {}, name {}>").format(self.id, self.name)

    def as_dict(self):
        return {"id": self.id, "name": self.name}
Example #14
0
class Error(BaseModel):
    __tablename__ = 'ERROR'
    id = db.Column('ID', INTEGER(unsigned=True), primary_key=True, unique=True)
    error = db.Column('ERROR', db.String(1000), nullable=True)

    analysis_id = db.Column('ANALYSIS_ID', INTEGER(unsigned=True),
                            db.ForeignKey('ANALYSIS.ID'))

    def __init__(self, error, analysis_id):
        self.error = error
        self.analysis_id = analysis_id

    def __repr__(self):
        return ("<id {}, error {}>").format(self.id, self.error)

    def as_dict(self):
        return {
            "id": self.id,
            "error": self.error,
            "analysis_id": self.analysis_id
        }
Example #15
0
class AnalysisToolsDetails(BaseModel):
    __tablename__ = 'ANALYSIS_TOOLS_DETAILS'
    id = db.Column('ID', INTEGER(unsigned=True), primary_key=True, unique=True)
    pipeline_call = db.Column('PIPELINE_CALL', db.String(20), nullable=True)
    current_call = db.Column('CURRENT_CALL', db.String(20), nullable=True)
    pipeline_msg = db.Column('PIPELINE_MSG', db.String(500), nullable=True)
    current_msg = db.Column('CURRENT_MSG', db.String(500), nullable=True)
    current_detail = db.Column('CURRENT_DETAIL', db.Text, nullable=True)

    analysis_id = db.Column('ANALYSIS_ID', INTEGER(unsigned=True),
                            db.ForeignKey('ANALYSIS.ID'))
    tool_id = db.Column('TOOL_ID', INTEGER(unsigned=True),
                        db.ForeignKey('ANALYSIS_TOOLS.ID'))

    pipeline_detail = None
    custom_pipeline_detail = None

    def __init__(self, pipeline_call, current_call, pipeline_msg, current_msg,
                 current_detail, analysis_id, tool_id):
        self.pipeline_call = pipeline_call
        self.current_call = current_call
        self.pipeline_msg = pipeline_msg
        self.current_msg = current_msg
        self.current_detail = current_detail
        self.analysis_id = analysis_id
        self.tool_id = tool_id

    def __repr__(self):
        return ("<id {}, tool {}, pipeline_call {}>").format(
            self.id, self.tool_id, self.pipeline_call)

    def as_dict(self):
        return {
            "id": self.id,
            "pipeline_call": self.pipeline_call,
            "current_call": self.current_call,
            "pipeline_msg": self.pipeline_msg,
            "current_msg": self.current_msg,
            "pipeline_detail": self.pipeline_detail,
            "current_detail": self.current_detail,
            "custom_pipeline_detail": self.custom_pipeline_detail,
            "analysis_id": self.analysis_id,
            "tool_id": self.tool_id
        }
class MapAnalysisJunctions(db.Model):
    __tablename__ = 'MAP_ANALYSIS_JUNCTIONS'
    id = db.Column('ID', INTEGER(unsigned=True), primary_key=True, unique=True)

    map_analysis_id = db.Column('MAP_ANALYSIS_ID', INTEGER(unsigned=True),
                                db.ForeignKey('MAP_ANALYSIS.ID'))
    junction_id = db.Column('JUNCTION_ID', INTEGER(unsigned=True),
                            db.ForeignKey('JUNCTION.ID'))

    junction = db.relationship('Junction', backref='junctions', lazy=True)

    masked = db.Column('MASKED', db.Boolean, default=False, nullable=False)
    junction_comment = db.Column('COMMENT', db.String(500), nullable=True)
    masked_by = db.Column('COMMENTED_BY',
                          db.String(50),
                          db.ForeignKey('USER_ROLE.USERNAME'),
                          default='system',
                          nullable=True)

    def __init__(self, map_analysis_id, junction_id, masked, junction_comment,
                 masked_by):
        self.map_analysis_id = map_analysis_id
        self.junction_id = junction_id
        self.masked = masked
        self.junction_comment = junction_comment
        self.masked_by = masked_by

    def __repr__(self):
        return (
            "<id {}, map_analysis_id {}, junction_id {}, masked {}, junction_comment {}, masked_by {}"
        ).format(self.id, self.map_analysis_id, self.junction_id, self.masked,
                 self.junction_comment, self.masked_by)

    def as_dict(self):
        return {
            "id": self.id,
            "map_analysis_id": self.map_analysis_id,
            "junction_id": self.junction_id,
            "masked": self.masked,
            "junction_comment": self.junction_comment,
            "masked_by": self.masked_by
        }
Example #17
0
class Variation(BaseModel):
    __tablename__ = 'VARIATION'
    id = db.Column('ID', INTEGER(unsigned=True), primary_key=True, unique=True)
    position = db.Column('POSITION', BIGINT(unsigned=True), nullable=True)
    type = db.Column('TYPE', db.String(10), nullable=True)
    ref_base = db.Column('REF_BASE', db.String(100), nullable=True)
    sample_base = db.Column('SAMPLE_BASE', db.String(100), nullable=True)
    translation = db.Column('TRANSLATION', db.String(200), nullable=True)
    coverage = db.Column('COVERAGE', BIGINT(unsigned=True), nullable=True)
    purity = db.Column('PURITY', DECIMAL(6, 5), nullable=True)
    tier = db.Column('TIER', db.String(20), nullable=True)
    read_depth = db.Column('READ_DEPTH', db.String(20), nullable=True)
    annotation = db.Column('ANNOTATION', db.String(100), nullable=True)
    tier_label = db.Column('TIER_LABEL', db.String(20), nullable=True)
    gt = db.Column('GT', db.String(20), nullable=True)
    total_read_depth = db.Column('TOTAL_READ_DEPTH',
                                 db.String(20),
                                 nullable=True)
    feature_type = db.Column('FEATURE_TYPE', db.String(50), nullable=True)
    effects = db.Column('EFFECTS', db.String(50), nullable=True)
    organism = db.Column('ORGANISM', db.String(20), nullable=True)
    is_tier_label_updated = db.Column('IS_TIER_LABEL_UPDATED',
                                      db.Boolean,
                                      default=False,
                                      nullable=False)

    map_analysis_id = db.Column('MAP_ANALYSIS_ID', INTEGER(unsigned=True),
                                db.ForeignKey('MAP_ANALYSIS.ID'))

    construct_id = None
    sample_id = None
    lab_name = None

    def __init__(self, position, type, ref_base, sample_base, translation,
                 coverage, purity, tier, read_depth, annotation, tier_label,
                 is_tier_label_updated, gt, total_read_depth, feature_type,
                 effects, organism, map_analysis_id):
        self.position = position
        self.type = type
        self.ref_base = ref_base
        self.sample_base = sample_base
        self.translation = translation
        self.coverage = coverage
        self.purity = purity
        self.tier = tier
        self.read_depth = read_depth
        self.annotation = annotation
        self.tier_label = tier_label
        self.is_tier_label_updated = is_tier_label_updated
        self.gt = gt
        self.total_read_depth = total_read_depth
        self.feature_type = feature_type
        self.effects = effects
        self.organism = organism
        self.map_analysis_id = map_analysis_id

    def __repr__(self):
        return (
            "<id {}, type {}, tier {}, annotation {}, tier_label {}>").format(
                self.id, self.type, self.tier, self.annotation,
                self.tier_label)

    def as_dict(self):
        return {
            "id":
            self.id,
            "sample_id":
            self.sample_id,
            "lab_name":
            self.lab_name,
            "position":
            self.position,
            "type":
            self.type,
            "ref_base":
            self.ref_base,
            "sample_base":
            self.sample_base,
            "translation":
            self.translation,
            "coverage":
            self.coverage,
            "purity":
            self.purity,
            "tier":
            self.tier,
            "read_depth":
            self.read_depth,
            "annotation":
            self.annotation,
            "tier_label":
            self.tier_label,
            "gt":
            self.gt,
            "total_read_depth":
            self.total_read_depth,
            "feature_type":
            self.feature_type,
            "effects":
            self.effects,
            "organism":
            self.organism,
            "map_analysis_id":
            self.map_analysis_id,
            "construct_id":
            self.construct_id,
            "is_tier_label_updated":
            "true" if self.is_tier_label_updated else "false"
        }
Example #18
0
class Request(BaseModel):
    __tablename__ = 'REQUEST'
    id = db.Column('ID', INTEGER(unsigned=True), primary_key=True, unique=True)
    request_id = db.Column('REQUEST_ID', db.String(50), nullable=True)
    sample_prep_methods = db.Column('SAMPLE_PREP_METHODS',
                                    db.String(20),
                                    nullable=True)
    sbs_internalpipeline_version = db.Column('SBS_INTERNALPIPELINE_VERSION',
                                             db.String(20),
                                             nullable=True)
    request_name = db.Column('REQUEST_NAME', db.String(20), nullable=True)
    released_on = db.Column('RELEASED_ON',
                            db.TIMESTAMP,
                            default=db.func.now(),
                            nullable=False)
    sbs_status = db.Column('SBS_STATUS', db.String(20), nullable=True)
    researcher = db.Column('RESEARCHER', db.String(50), nullable=True)

    tx_method_id = db.Column('TX_METHOD', INTEGER(unsigned=True),
                             db.ForeignKey('TX_METHOD.ID'))
    organism_id = db.Column('ORGANISM', INTEGER(unsigned=True),
                            db.ForeignKey('CROP.ID'))

    samples = db.relationship('Sample', backref='request', lazy='dynamic')
    request_comment = db.relationship('RequestComment',
                                      backref='requests',
                                      lazy='dynamic')

    load_date = ""
    tx_method = ""
    sample_type = ""
    organism = ""
    alpha_samples, delta_samples, total_comments, total_errors, total_samples = (
        0, 0, 0, 0, 0)

    def __init__(self, request_id, sample_prep_methods,
                 sbs_internalpipeline_version, request_name, released_on,
                 sbs_status, researcher, tx_method_id, organism_id):
        self.request_id = request_id
        self.organism_id = organism_id
        self.sample_prep_methods = sample_prep_methods
        self.sbs_internalpipeline_version = sbs_internalpipeline_version
        self.request_name = request_name
        self.released_on = released_on
        self.sbs_status = sbs_status
        self.researcher = researcher
        self.tx_method_id = tx_method_id

    def __repr__(self):
        return ("<id {}, request_id {}, sbs_internalpipeline_version {}, "
                "request_name {}>").format(self.id, self.request_id,
                                           self.sbs_internalpipeline_version,
                                           self.request_name)

    def as_dict(self):
        return {
            "id": self.id,
            "request_id": self.request_id,
            "sample_prep_methods": self.sample_prep_methods,
            "sbs_internalpipeline_version": self.sbs_internalpipeline_version,
            "sbs_status": self.sbs_status,
            "request_name": self.request_name,
            "released_on": self.released_on,
            "researcher": self.researcher,
            "tx_method_id": self.tx_method_id,
            "organism_id": self.organism_id
        }

    def browse_request_as_dict(self):
        return {
            "id": self.id,
            "request_id": self.request_id,
            "alpha_samples": self.alpha_samples if self.alpha_samples else '',
            "delta_samples": self.delta_samples if self.delta_samples else '',
            "sbs_internalpipeline_version": self.sbs_internalpipeline_version,
            "request_name": self.request_name,
            "status": self.sbs_status if self.sbs_status else '',
            "researcher": self.researcher if self.researcher else '',
            "load_date": self.load_date if self.load_date else '',
            "tx_method": self.tx_method if self.tx_method else '',
            "organism": self.organism if self.organism else '',
            "tx_method_id": self.tx_method_id,
            "total_comments": self.total_comments,
            "total_errors": self.total_errors
        }

    def browse_request_client_as_dict(self):
        return {
            "id": self.id,
            "request_id": self.request_id,
            "request_name": self.request_name,
            "status": self.sbs_status if self.sbs_status else '',
            "researcher": self.researcher if self.researcher else '',
            "load_date": self.load_date if self.load_date else '',
            "tx_method": self.tx_method if self.tx_method else '',
            "organism": self.organism if self.organism else '',
            "tx_method_id": self.tx_method_id,
            "total_samples": self.total_samples
        }
Example #19
0
class ObservedMap(BaseModel):
    __tablename__ = 'OBSERVED_MAP'
    id = db.Column('ID', INTEGER(unsigned=True), primary_key=True, unique=True)
    name = db.Column('NAME', db.String(50), nullable=True)
    load_time = db.Column('LOAD_TIME', db.TIMESTAMP, nullable=False)
    length = db.Column('LENGTH', BIGINT(unsigned=True), nullable=True)
    status = db.Column('STATUS', db.String(50), nullable=True)
    send_to_evman = db.Column('SEND_TO_EVMAN', db.Boolean, default=False,
                              nullable=False)
    version = db.Column('VERSION', BIGINT(unsigned=True), nullable=True)

    map_id = db.Column('MAP_ID', INTEGER(unsigned=True),
                       db.ForeignKey('MAP.ID'))
    comments = db.relationship('ObservedMapComment',
                               backref='comment_observed_map', lazy='dynamic',
                               passive_deletes=True)

    run_id = "1"
    sample_id = None
    analysis_id = None
    sample_name = None
    event_id = None
    analysis_type = None
    map_name = None
    construct_id = None

    def __init__(self, name, load_time, length, status, send_to_evman,
                 map_id, version):
        self.name = name
        self.load_time = load_time
        self.length = length
        self.status = status
        self.send_to_evman = send_to_evman
        self.map_id = map_id
        self.version = version

    def __repr__(self):
        return (
            "<id {}, name {}>").format(
            self.id,
            self.name)

    def as_dict(self):
        return {
            "id": self.id,
            "name": self.name,
            "load_time": self.load_time,
            "length": self.length,
            "status": self.status,
            "send_to_evman": self.send_to_evman,
            "map_id": self.map_id,
            "construct_id": self.construct_id,
            "sample_id":  self.sample_id,
            "analysis_id":  self.analysis_id,
            "version":  self.version
        }

    def browse_as_dict(self):
        return {
            "id": self.id,
            "name": self.name if self.name else '',
            "load_time": str(self.load_time),
            "length": self.length if self.length else '',
            "status": self.status if self.status else '',
            "send_to_evman":  self.send_to_evman,
            "map_id": self.map_id if self.map_id else '',
            "sample_id":  self.sample_id if self.sample_id else '',
            "sample_name": self.sample_name if self.sample_name else '',
            "event_id": self.event_id if self.event_id else '',
            "analysis_type": self.analysis_type if self.analysis_type else '',
            "run_id": self.run_id if self.run_id else '',
            "modified_time": str(self.updated_on),
            "map_name": self.map_name if self.map_name else '',
            "version": self.version
        }
Example #20
0
 def updated_by(cls):
     return db.Column('UPDATED_BY',
                      db.String(50),
                      db.ForeignKey('USER_ROLE.USERNAME'),
                      default='system',
                      nullable=False)
Example #21
0
class Sample(BaseModel):
    __tablename__ = 'SAMPLE'
    id = db.Column('ID', INTEGER(unsigned=True), primary_key=True, unique=True)
    sample_id = db.Column('SAMPLE_ID', db.String(50), nullable=True)
    primary_map = db.Column('PRIMARY_MAP', db.String(50), nullable=True)
    ev_man_event = db.Column('EV_MAN_EVENT', db.String(50), nullable=True)
    other_maps = db.Column('OTHER_MAPS', db.String(50), nullable=True)
    construct_name = db.Column('CONSTRUCT_NAME', db.String(50), nullable=True)
    event_id = db.Column('EVENT_ID', db.String(20), nullable=True)
    geno_type = db.Column('GENO_TYPE', db.String(500), nullable=True)
    organism = db.Column('ORGANISM', db.String(20), nullable=True)
    sample_name = db.Column('SAMPLE_NAME', db.String(20), nullable=True)
    develop_stage = db.Column('DEVELOP_STAGE', db.String(20), nullable=True)
    growth_location = db.Column('GROWTH_LOCATION', db.String(50), nullable=True)
    treated = db.Column('TREATED', db.Boolean, default=False, nullable=False)
    eu_id = db.Column('EU_ID', db.String(50), nullable=True)

    request_id = db.Column('REQUEST_ID', INTEGER(unsigned=True), db.ForeignKey('REQUEST.ID'))
    curr_alpha_analysis = db.Column('CURR_ALPHA_ANALYSIS', INTEGER(unsigned=True),
                                    db.ForeignKey('ANALYSIS.ID', use_alter=True, name='fk_sample_analysis_id'))
    curr_alpha = db.relationship('Analysis', foreign_keys=curr_alpha_analysis, post_update=True)
    # reads = db.Column('READS', INTEGER(unsigned=True), db.ForeignKey('FLAT_Q_FILE_FOR_READS.ID'))

    pipeline_call = ""
    current_call = ""
    status = ""
    load_date = ""
    type = ""
    is_visible = ""
    analysis_id = None
    total_maps, total_errors, total_varitaions, total_samples = (0, 0, 0, 0)
    single_read_count = None
    paired_read_count = None
    complete_probe_coverage = ""
    target_rate = ""
    tier_3_reason = ""
    sbs_version = ""
    reference = ""
    observed_map_id = None
    construct_ids = {}
    analysis_geno_type = ""
    backbone_call = ""
    analysis_event_id = ""
    req_id = ""
    request_name = ""
    researcher = ""
    request_organism = ""
    comments = {}
    manual_set = ""
    call_comment = ""
    total_pending_maps = 0
    configuration_id = None

    def __init__(self, sample_id, primary_map, ev_man_event, other_maps,
                 request_id, construct_name, event_id, geno_type, organism,
                 sample_name, develop_stage, growth_location, treated, eu_id,
                 curr_alpha_analysis):
        self.sample_id = sample_id
        self.primary_map = primary_map
        self.ev_man_event = ev_man_event
        self.other_maps = other_maps
        self.request_id = request_id
        self.construct_name = construct_name
        self.event_id = event_id
        self.geno_type = geno_type
        self.organism = organism
        self.sample_name = sample_name
        self.develop_stage = develop_stage
        self.growth_location = growth_location
        self.treated = treated
        self.eu_id = eu_id
        self.curr_alpha_analysis = curr_alpha_analysis
        # self.reads = reads

    def __repr__(self):
        return (
            "<id {}, event_id {}, request_id {}>").format(
            self.id,
            self.event_id,
            self.request_id)

    def as_dict(self):
        return {
            "id": self.id,
            "sample_id": self.sample_id,
            "primary_map": self.primary_map,
            "other_maps": self.other_maps,
            "request_id": self.request_id,
            "construct_name": self.construct_name,
            "event_id": self.event_id,
            "geno_type": self.geno_type,
            "organism": self.organism,
            "sample_name": self.sample_name,
            "develop_stage": self.develop_stage,
            "growth_location": self.growth_location,
            "treated": self.treated,
            "eu_id": self.eu_id,
            "curr_alpha_analysis": self.curr_alpha_analysis
        }

    def browse_sample_as_dict(self):
        return {
            "id": self.id,
            "analysis_id": self.analysis_id,
            "sample_id": self.sample_id,
            "sample_name": self.sample_name,
            "construct_name": self.construct_name,
            "event_id": self.event_id,
            "geno_type": self.geno_type,
            "eu_id": self.eu_id,
            "develop_stage": self.develop_stage,
            "curr_alpha_analysis": self.curr_alpha_analysis,
            "pipeline_call": self.pipeline_call if self.pipeline_call else '',
            "current_call": self.current_call if self.current_call else '',
            "status": self.status if self.status else '',
            "load_date": self.load_date,
            "type": str(self.type.value) if self.type else "",
            "is_visible_to_cilent": "Yes" if self.is_visible else "No",
            "total_variations": self.total_variations,
            "total_maps": self.total_maps,
            "total_errors": self.total_errors if self.total_maps else 0,
            "single_read_count": self.single_read_count,
            "paired_read_count": self.paired_read_count,
            "complete_probe_coverage": self.complete_probe_coverage,
            "target_rate": self.target_rate,
            "tier_3_reason": self.tier_3_reason,
            "sbs_version": self.sbs_version,
            "modified_date": self.updated_on,
            "reference_genome": self.reference,
            "observed_map_id": self.observed_map_id,
            "construct_ids": self.construct_ids,
            "analysis_geno_type": self.analysis_geno_type,
            "backbone_call": self.backbone_call,
            "analysis_event_id": self.analysis_event_id,
            "request_id": self.req_id,
            "researcher": self.researcher,
            "request_name": self.request_name,
            "request_date": "",
            "organism": self.request_organism,
            "comments": self.comments,
            "Department": "",
            "department": "",
            "read_count": "",
            "endogenous_set": "",
            "expected_php": "",
            "experiment_summary": "",
            "lab_name": "",
            "manual_set": self.manual_set if self.manual_set else '',
            "call_comment": self.call_comment if self.call_comment else '',
            "total_pending_maps": self.total_pending_maps if self.total_pending_maps else 0,
            "configuration_id": self.configuration_id
        }
Example #22
0
class Junction(BaseModel):
    __tablename__ = 'JUNCTION'
    id = db.Column('ID', INTEGER(unsigned=True), primary_key=True, unique=True)
    end = db.Column('END', db.String(50), nullable=True)
    position = db.Column('POSITION', BIGINT(unsigned=True), nullable=True)
    proximal_mapping = db.Column('PROXIMAL_MAPPING',
                                 db.String(50),
                                 nullable=True)
    proximal_percent_identity = db.Column('PROXIMAL_PERCENT_IDENTITY',
                                          db.String(50),
                                          nullable=True)
    proximal_sequence = db.Column('PROXIMAL_SEQUENCE', db.Text, nullable=True)
    junction_sequence = db.Column('JUNCTION_SEQUENCE', db.Text, nullable=True)
    distal_sequence = db.Column('DISTAL_SEQUENCE', db.Text, nullable=True)
    proximal_sequence_length = db.Column('PROXIMAL_SEQUENCE_LENGTH',
                                         BIGINT(unsigned=True),
                                         nullable=True)
    distal_mapping = db.Column('DISTAL_MAPPING', db.Text, nullable=True)
    distal_percent_identity = db.Column('DISTAL_PERCENT_IDENTITY',
                                        db.String(50),
                                        nullable=True)
    distal_sequence_length = db.Column('DISTAL_SEQUENCE_LENGTH',
                                       BIGINT(unsigned=True),
                                       nullable=True)
    element = db.Column('ELEMENT', db.String(50), nullable=True)
    unique_reads = db.Column('UNIQUE_READS',
                             BIGINT(unsigned=True),
                             nullable=True)
    supporting_reads = db.Column('SUPPORTING_READS',
                                 BIGINT(unsigned=True),
                                 nullable=True)
    endogenous = db.Column('ENDOGENOUS',
                           db.Boolean,
                           default=False,
                           nullable=False)
    source = db.Column('SOURCE', db.String(50), nullable=True)
    duplicates = db.Column('DUPLICATES', db.String(50), nullable=True)

    duplicates_dict = {}
    proximal_percent = None
    distal_percent = None
    masked = None
    masked_by = None
    comment = None

    def __init__(self, end, position, proximal_mapping,
                 proximal_percent_identity, proximal_sequence,
                 junction_sequence, proximal_sequence_length, distal_sequence,
                 distal_mapping, distal_percent_identity,
                 distal_sequence_length, element, unique_reads,
                 supporting_reads, endogenous, source, duplicates):
        self.end = end
        self.position = position
        self.proximal_mapping = proximal_mapping
        self.proximal_percent_identity = proximal_percent_identity
        self.proximal_sequence = proximal_sequence
        self.junction_sequence = junction_sequence
        self.distal_sequence = distal_sequence
        self.proximal_sequence_length = proximal_sequence_length
        self.distal_mapping = distal_mapping
        self.distal_percent_identity = distal_percent_identity
        self.distal_sequence_length = distal_sequence_length
        self.element = element
        self.unique_reads = unique_reads
        self.supporting_reads = supporting_reads
        self.endogenous = endogenous
        self.source = source
        self.duplicates = duplicates

    def __repr__(self):
        return (
            "<id {}, proximal_mapping {}, percent_identity {}, proximal{}, sequence{}, length{}, distal_mapping{},"
            " distal_percent_identity{}, distal_sequence_length{}, element{}, unique_reads{}, supporting_reads{}"
            ">").format(
                self.id,
                self.proximal_mapping,
                self.proximal_percent_identity,
                self.proximal_sequence,
                self.junction_sequence,
                self.proximal_sequence_length,
                self.distal_mapping,
                self.distal_percent_identity,
                self.distal_sequence_length,
                self.element,
                self.unique_reads,
                self.supporting_reads,
            )

    def as_dict(self):
        return {
            "id": self.id,
            "end": self.end,
            "position": self.position,
            "proximal_mapping": self.proximal_mapping,
            "proximal_percent_identity": self.proximal_percent_identity,
            "proximal_sequence": self.proximal_sequence,
            "junction_sequence": self.junction_sequence,
            "distal_sequence": self.distal_sequence,
            "proximal_sequence_length": self.proximal_sequence_length,
            "distal_mapping": self.distal_mapping,
            "distal_percent_identity": self.distal_percent_identity,
            "distal_sequence_length": self.distal_sequence_length,
            "element": self.element,
            "unique_reads": self.unique_reads,
            "masked": 'True' if self.masked else 'False',
            "supporting_reads": self.supporting_reads,
            "endogenous": 'True' if self.endogenous else 'False',
            "source": self.source,
            "duplicates": self.duplicates
        }

    def convert_proximal_mapping(self):
        prox_map_str = ""
        if self.proximal_mapping:
            prox_map_arr = self.proximal_mapping.split(",")
            if len(prox_map_arr) == 4:
                construct_id, map_start_loc, map_end_loc, percent = prox_map_arr
                self.proximal_percent = percent
                prox_map_str = construct_id + ":" + map_start_loc + "-" + map_end_loc

        return prox_map_str

    def convert_distal_mapping(self):
        distal_map_str = ""
        if self.distal_mapping and self.distal_sequence_length:
            distal_map_arr = self.distal_mapping.split(",")
            if len(distal_map_arr) == 4:
                chromosome, map_start_loc, map_end_loc, percent = distal_map_arr
                self.distal_percent = percent
                distal_map_str = "Distal:1-" + str(self.distal_sequence_length) + "=>" \
                                 + chromosome + ":" + map_start_loc + "-" + map_end_loc + " " + percent

        return distal_map_str

    def browse_junction_as_dict(self):
        return {
            "id": self.id,
            "end": self.end,
            "position": self.position,
            "proximal_mapping": self.convert_proximal_mapping(),
            "proximal_percent_identity": self.proximal_percent_identity,
            "proximal_sequence_length": self.proximal_sequence_length,
            "distal_mapping_percent_identity": self.convert_distal_mapping(),
            "proximal_percent": self.proximal_percent,
            "distal_percent:": self.distal_percent,
            "distal_percent_identity": self.distal_percent_identity,
            "distal_sequence": self.distal_sequence,
            "distal_sequence_length": self.distal_sequence_length,
            "element": self.element,
            "unique_reads": self.unique_reads,
            "supporting_reads": self.supporting_reads,
            "masked": self.masked,
            "masked_by": self.masked_by,
            "comment": self.comment,
            "duplicates_dict": self.duplicates_dict,
            "junction_sequence": self.junction_sequence,
            "source": self.source
        }
Example #23
0
class Analysis(BaseModel):
    __tablename__ = 'ANALYSIS'
    id = db.Column('ID', INTEGER(unsigned=True), primary_key=True, unique=True)
    input_map = db.Column('INPUT_MAP', db.String(20), nullable=True)
    type = db.Column('TYPE', db.Enum(RequestType))
    reference = db.Column('REFERENCE', db.String(20), nullable=True)
    job_status = db.Column('JOB_STATUS', db.String(20), nullable=True)
    sbs_status = db.Column('SBS_STATUS', db.String(50), nullable=True)
    sbs_version = db.Column('SBS_VERSION', db.String(50), nullable=True)
    pipeline_call = db.Column('PIPELINE_CALL', db.String(20), nullable=True)
    current_call = db.Column('CURRENT_CALL', db.String(20), nullable=True)
    geno_type = db.Column('GENO_TYPE', db.String(20), nullable=True)
    event_id = db.Column('EVENT_ID', db.String(20), nullable=True)
    backbone_call = db.Column('BACKBONE_CALL', db.String(20), nullable=True)
    released_on = db.Column('RELEASED_ON', db.String(20), nullable=True)
    sample_call = db.Column('SAMPLE_CALL', db.String(20), nullable=True)
    sbs_integ_tier = db.Column('SBS_INTEG_TIER', db.String(20), nullable=True)
    vqc_ali_pct = db.Column('VQC_ALI_PCT', db.String(20), nullable=True)
    is_deprecated = db.Column('IS_DEPRECATED',
                              db.Boolean,
                              default=False,
                              nullable=False)
    load_date = db.Column('LOAD_DATE', db.TIMESTAMP, nullable=True)
    is_visible_to_client = db.Column('IS_VISIBLE_TO_CLIENT',
                                     db.Boolean,
                                     default=False,
                                     nullable=False)
    single_read_count = db.Column('SINGLE_READ_COUNT',
                                  BIGINT(unsigned=True),
                                  nullable=True)
    paired_read_count = db.Column('PAIRED_READ_COUNT',
                                  BIGINT(unsigned=True),
                                  nullable=True)
    complete_probe_coverage = db.Column('COMPLETE_PROBE_COVERAGE',
                                        db.Boolean,
                                        default=False,
                                        nullable=False)
    target_rate = db.Column('ON_TARGET_RATE', db.String(20), nullable=True)
    tier_3_reason = db.Column('TIER_3_REASON', db.String(20), nullable=True)
    manual_set = db.Column('MANUAL_SET', db.String(50), nullable=True)
    call_comment = db.Column('CALL_COMMENT', db.String(50), nullable=True)

    sample_id = db.Column('SAMPLE_ID', INTEGER(unsigned=True),
                          db.ForeignKey('SAMPLE.ID'))
    configuration_id = db.Column('CONFIGURATION_ID', INTEGER(unsigned=True),
                                 db.ForeignKey('PIPELINE_CONFIGURATION.ID'))
    sample = db.relationship('Sample',
                             foreign_keys=sample_id,
                             backref='analysis')
    error_id = db.relationship('Error', backref='analysis', lazy='dynamic')
    map_analysis = db.relationship('MapAnalysis',
                                   backref='analysis_map',
                                   lazy='dynamic')
    comments = db.relationship('AnalysisComment',
                               backref='analysis',
                               lazy='dynamic')

    #analysis_tools_details = db.relationship('AnalysisToolsDetails', backref='analysisToolsDetails', lazy='dynamic')

    def __init__(self, input_map, type, sample_id, reference, job_status,
                 sbs_status, sbs_version, pipeline_call, current_call,
                 geno_type, event_id, backbone_call, released_on, sample_call,
                 sbs_integ_tier, vqc_ali_pct, is_deprecated, load_date,
                 is_visible_to_client, single_read_count, paired_read_count,
                 complete_probe_coverage, target_rate, tier_3_reason,
                 manual_set, call_comment, configuration_id):
        self.input_map = input_map
        self.type = type
        self.sample_id = sample_id
        self.reference = reference
        self.job_status = job_status
        self.sbs_status = sbs_status
        self.sbs_version = sbs_version
        self.pipeline_call = pipeline_call
        self.current_call = current_call
        self.geno_type = geno_type
        self.event_id = event_id
        self.backbone_call = backbone_call
        self.released_on = released_on
        self.sample_call = sample_call
        self.sbs_integ_tier = sbs_integ_tier
        self.vqc_ali_pct = vqc_ali_pct
        self.is_deprecated = is_deprecated
        self.load_date = load_date
        self.is_visible_to_client = is_visible_to_client
        self.single_read_count = single_read_count
        self.paired_read_count = paired_read_count
        self.complete_probe_coverage = complete_probe_coverage
        self.target_rate = target_rate
        self.tier_3_reason = tier_3_reason
        self.manual_set = manual_set
        self.call_comment = call_comment
        self.configuration_id = configuration_id

    def __repr__(self):
        return ("<id {}, sample_id {}, event_id {}>").format(
            self.id, self.sample_id, self.event_id)

    def as_dict(self):
        return {
            "id": self.id,
            "input_map": self.input_map,
            "type": self.type,
            "sample_id": self.sample_id,
            "reference": self.reference,
            "job_status": self.job_status,
            "sbs_status": self.sbs_status,
            "sbs_version": self.sbs_version,
            "pipeline_call": self.pipeline_call,
            "current_call": self.current_call,
            "geno_type": self.geno_type,
            "event_id": self.event_id,
            "backbone_call": self.backbone_call,
            "released_on": self.released_on,
            "sample_call": self.sample_call,
            "sbs_integ_tier": self.sbs_integ_tier,
            "vqc_ali_pct": self.vqc_ali_pct,
            "is_deprecated": self.is_deprecated,
            "load_date": self.load_date,
            "is_visible_to_client":
            "true" if self.is_visible_to_client else "false",
            "single_read_count": self.single_read_count,
            "paired_read_count": self.paired_read_count,
            "complete_probe_coverage": self.complete_probe_coverage,
            "target_rate": self.target_rate,
            "tier_3_reason": self.tier_3_reason,
            "manual_set": self.manual_set,
            "call_comment": self.call_comment,
            "configuration_id": self.configuration_id
        }