Best Python code snippet using tempest_python
parse_gtf_exons.py
Source:parse_gtf_exons.py  
...44                    genes[d['gene_id']][d['transcript_id']] = [t]45            else:46                genes[d['gene_id']] = {d['transcript_id']: [t]}47    return genes48def find_skips(exons1, exons2):49    pat1 = ''.join(['T' if k in exons1 else 'F' for k in exons2])50    pat2 = ''.join(['T' if k in exons2 else 'F' for k in exons1])51    if re.match(r"""TF+T""", pat1) or re.match(r"""TF+T""", pat2):52        return True53    else:54        return False55def find_skipped_exons(mytranscripts):56    myexons = {k: [t[8]['exon_id'] for t in v] for k,v in mytranscripts.items()}57    for i, ex1 in enumerate(myexons.values()):58        for ex2 in myexons.values()[i+1:]:59            if find_skips(ex1, ex2):60                return True61    return False62if 'exons' not in locals():63    print 'Reading exons'64    exons = read_exons(fname)65if 'transcripts' not in locals():66    print 'Reading transcripts'67    transcripts = read_transcripts(fname)68print 'Finding skips'69hasskips = [find_skipped_exons(k) for k in transcripts.values()]70geneskips = pd.DataFrame(hasskips, index=transcripts.keys())71geneskips = geneskips.sort_index()...utils.py
Source:utils.py  
...15    final_index = 0  # position of selected file/folder in its list16    # Final position of element will always be of the form data[folder_index][contents_index][final_index]17    for i in range(len(selection) - 1):18        for j in range(selection[i]):19            folder_index += find_skips(data, folder_index)[0]20        folder_index += 121    folder_index -= 122    if selection[-1] >= len(data[folder_index][1]):23        # search inside files list24        contents_index = 225        final_index = selection[-1] - len(data[folder_index][1])26    else:27        contents_index = 128        final_index = selection[-1]29    selection_name = data[folder_index][contents_index][final_index]30    selection_path = os.path.join(data[folder_index][0], selection_name)31    return_dict = {"path": selection_path, "name": selection_name, "type": ""}32    if os.path.isfile(selection_path):33        return_dict["type"] = "file"34    else:35        return_dict["type"] = "folder"36    return return_dict37    # print(folder_index, contents_index, final_index)38    # print(data[folder_index][contents_index][final_index])39    # print(selection)40def find_skips(data, index):41    if len(data[index][1]) == 0:42        return [1, 0]43    output = [1, 0]44    sum = 045    for i in range(len(data[index][1])):46        if index == 7:47            print(index + sum + 1)48        rec = find_skips(data, index + sum + 1)49        sum += rec[1] + 150        output[0] += rec[0]51    output[1] = len(data[index][1])...app.py
Source:app.py  
...17    if auth_key_submitted != auth_key:18        return jsonify({"status": "unauthorized"}), 40119    tmp_storage.update(seq)20    # immediately count the number of steps in this chunk sent by the client21    skips_count = find_skips(seq)22    # also, keep "tmp_count" updated with the number of skips that we have23    # currently (i.e. since the latest storage) sent the client24    tmp_count += skips_count25    print(len(tmp_storage)) # debug message (TODO: use logging)26    if len(tmp_storage) > 500:27        min_ts = min(tmp_storage.keys())28        # now count the "correct" number of skips (i.e. on the entire "tmp_storage" buffer29        # The result is then compared with "tmp_count" (the count that has been sent thus far)30        # Only the delta is sent (to provide the correct count to the client)31        skips_count = find_skips(tmp_storage) # "true" count32        # now skips_count contains the "adjusting" value (i.e. the offset from what we33        # previously told the client to the "correct" number. We send this offset so34        # that the client has a valid estimate (can be positive or negative)35        skips_count = skips_count - tmp_count 36        with open(os.path.join(outdir, f"{min_ts}.json"), "w") as f:37            json.dump(tmp_storage, f)38            tmp_storage = {}39            tmp_count = 0 # reset count40    return jsonify({"status": "OK", "count": skips_count }), 20041    42if __name__ == "__main__":...Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!
