Esempio n. 1
0
def process_report(report):
    """
    Parse a pit XML report - returns a dict of unique mutants and a score
    """
    mutant_dict = {}
    root = parse_report(report)
    for child in root:
        mutant = Mutant(child.attrib.get("detected"), child.attrib.get("status"), child[0].text, child[1].text, child[2].text,\
                child[3].text, child[4].text, child[5].text, child[6].text, child[7].text,  child[8].text)
        if mutant.key() not in mutant_dict:
            mutant_dict[mutant.key()] = mutant
    return mutant_dict
Esempio n. 2
0
def api_mutant():
    try:
        content = request.get_json()
        print(content, file=sys.stderr)
        adn = content.get('dna')
        mutant_classes = Mutant(adn)
    except Exception as e:
        print(e)
        result = False
        response = json.dumps({'error': result}), 400, {
            'ContentType': 'application/json'
        }
        return response
    # Function que valida que la cadena de ADN tenga la longitud y las letras correctas: devuelve True cuando tiene
    # el formato correcto y False cuando no
    result = mutant_classes.validate_adn_chain()
    if result:
        # funcion para validar si la en la BD ya tenemos dicha cadena de ADN salvada
        result = mutant_classes.validate_exist_dna()
        #Si es verdadera devolvemos el estatus, sino lo creamos
        if result['status'] == 0:
            response = app.response_class(status=403,
                                          mimetype='application/json',
                                          response=json.dumps(False))
            return response

        elif result['status'] == 1:
            response = app.response_class(status=200,
                                          mimetype='application/json',
                                          response=json.dumps(True))
            return response
        else:
            result = mutant_classes.create_dna_chain()
            if result:
                mutant_classes.save_dna(dna_status=1)
                response = app.response_class(status=200,
                                              mimetype='application/json',
                                              response=json.dumps(True))
                return response
            else:
                mutant_classes.save_dna(dna_status=0)
                response = app.response_class(status=403,
                                              mimetype='application/json',
                                              response=json.dumps(False))
                return response
    else:
        response = json.dumps({'error': result}), 403, {
            'ContentType': 'application/json'
        }

    return response
Esempio n. 3
0
def kunkel_full(protocol, params):
    growth_media = params["construct_setup"]['growth_media']
    #num_colonies = params["construct_setup"]['num_colonies']
    ssDNA = params["construct_setup"]['ssDNA']
    mutant_constructs = []

    # make mutant objects for accessibility
    construct_collect = {}
    for csv_row in params["construct_setup"]['mutant_upload']:
        if csv_row["mutant_label"] not in construct_collect.keys():
            construct_collect[csv_row["mutant_label"]] = []
            construct_collect[csv_row["mutant_label"]].append({
                "sequence":
                csv_row["sequence"],
                "purification":
                csv_row["purification"],
                "scale":
                csv_row["scale"],
                "oligo_label":
                csv_row["oligo_label"]
            })
        else:
            construct_collect[csv_row["mutant_label"]].append({
                "sequence":
                csv_row["sequence"],
                "purification":
                csv_row["purification"],
                "scale":
                csv_row["scale"],
                "oligo_label":
                csv_row["oligo_label"]
            })

    oligo_collect = {}
    for row in params["construct_setup"]["mutant_upload"]:
        if (row["sequence"] not in oligo_collect.keys()
                and row["oligo_label"] in protocol.refs.keys()):
            raise RuntimeError("You cannot specify two different "
                               "oligos to be synthesized with the "
                               "same name %s" % row['oligo_label'])
        elif row["sequence"] not in oligo_collect.keys():
            oligo_collect[row["sequence"]] = {
                "sequence":
                row["sequence"],
                "purification":
                row["purification"],
                "scale":
                row["scale"],
                "destination":
                protocol.ref(row["oligo_label"],
                             None,
                             "micro-2.0",
                             storage="cold_4").well(0)
            }

    for mut in construct_collect.keys():
        mut_oligos = [o for o in construct_collect[mut]]
        mutant = Mutant(mut)
        for oligo in mut_oligos:
            mutant.add_oligos(oligo_collect[oligo["sequence"]]["destination"])
        mutant_constructs.append(mutant)

    oligos_to_synthesize = []
    for o in oligo_collect.keys():
        scale_default(len(oligo_collect[o]["sequence"]),
                      oligo_collect[o]["scale"],
                      oligo_collect[o]["destination"].container.name)
        oligos_to_synthesize.append(oligo_collect[o])
    protocol.oligosynthesize(oligos_to_synthesize)

    assemble_params = {
        'ssDNA':
        ssDNA,
        'constructs': [{
            'mutant_name': mu.name,
            'oligos': mu.oligos
        } for mu in mutant_constructs],
        'mutant_objs':
        mutant_constructs
    }

    annealing_plate = assemble(protocol, assemble_params)
    protocol.unseal(annealing_plate)

    transform_params = {
        #'num_colonies': num_colonies,
        'growth_media': growth_media,
        'constructs': [mu.anneal_well for mu in mutant_constructs],
        'mutant_objs': mutant_constructs
    }

    # get agar plates back from transform protocol
    agar_plates = transform(protocol, transform_params)

    for agar_plate in agar_plates:
        protocol.cover(agar_plate)
Esempio n. 4
0
def classFactory(iface):
    from mutant import Mutant
    return Mutant(iface)
Esempio n. 5
0
from flask import Flask, request, abort
from mutant import Mutant, Stats
import os

app = Flask(__name__)
port = int(os.environ.get('PORT', 5000))

humano = Mutant()
estadisticas = Stats()


@app.route('/')
def index():
    return 'MeLi Challenge - Juan Fresneda'


@app.route('/mutant/', methods=['POST'])
def mutant():
    if not request.json or not 'dna' in request.json:
        abort(400)

    req_body = request.get_json()

    if humano.validate_dna(req_body['dna']):
        abort(400)
    if humano.is_mutant(req_body['dna']):
        return 'true'
    else:
        abort(403)

    def __init__(self,
                 screen,
                 fragment,
                 basesequence,
                 synth_from,
                 synth_to,
                 mut_from,
                 mut_to,
                 first_aa_coord,
                 num_barcodes=0,
                 ms=[],
                 ifi=[],
                 ifd=[],
                 ms_barcode_choices=[],
                 id_barcode_choices=[]):
        # Name of the MutantSet.
        self.screen = screen
        self.fragment = fragment
        # Sequence synthesis coords, 1-based, applies to entire
        # base sequence.
        self.synth_from = synth_from
        self.synth_to = synth_to
        # Sequence mutagenesis coords, 1-based, applies to entire
        # base sequence.
        self.mut_from = mut_from
        self.mut_to = mut_to
        # The cooridinate in the WT protein of the first amino acid
        # that is getting mutated. This is used for the GVCF notation
        # of the protein mutations.
        self.first_aa_coord = first_aa_coord

        # Store the number of bar codes per mutation to generate.
        self.num_barcodes = num_barcodes

        # Store the lists of missense, in-frame insertions (ifi's) and
        # in-frame deletions (ifd's) to be generated. If these
        # lists are empty then generate all of them.
        self.ms = ms[:]
        self.ifi = ifi[:]
        self.ifd = ifd[:]

        # Sequence being synthesized.
        self.synth_nt_sequence = basesequence[self.synth_from -
                                              1:self.synth_to]

        # Overhang sequences before and after coding regions.
        self.overhang_seq_5 = basesequence[self.synth_from - 1:self.mut_from -
                                           1]
        self.overhang_seq_3 = basesequence[self.mut_to:self.synth_to]

        # Sequence being mutated.
        self.coding_sequence = Mutant(
            self.screen, self.fragment,
            basesequence[self.mut_from - 1:self.mut_to], self.overhang_seq_5,
            self.overhang_seq_3, self.first_aa_coord)

        # The overhang_seq_5 + coding_sequence.nt_sequence + overhang_seq_3
        # should be identical to the synthesized sequence.
        assert len(self.overhang_seq_5) + len(
            self.coding_sequence.coding_sequence
        ) + len(self.overhang_seq_3) == len(
            self.synth_nt_sequence
        ), "Length of fragments (%d, %d, %d) != total synthesized length (%d)" % (
            len(self.overhang_seq_5), len(
                self.coding_sequence.coding_sequence), len(
                    self.overhang_seq_3), len(self.synth_nt_sequence))

        # Mutagenesis coords, 0-based, applies to synthesized
        # sequence.
        self.mut_from_0 = self.mut_from - self.synth_from
        self.mut_to_0 = self.mut_from_0 + (self.mut_to - self.mut_from)

        # List of mutants to be generated.
        self.mutants = []
Esempio n. 7
0
 def setUp(self):
     self.client = app
     self.humano = Mutant()
     self.estadistica = Stats()