Best Python code snippet using nose
stats_yacrd.py
Source:stats_yacrd.py
1#!/usr/bin/env python32import sys3import csv4import argparse5from Bio import SeqIO6from Bio.Seq import Seq7from Bio.SeqRecord import SeqRecord8def main(args):9 if args == None:10 args = sys.argv[1:]11 parser = argparse.ArgumentParser()12 parser.add_argument("-c", "--chimeric", required=True, help="chimeric read",13 type=argparse.FileType('r'))14 parser.add_argument("-y", "--yacrd", required=True, help="yacrd output",15 type=argparse.FileType('r'))16 args = vars(parser.parse_args(args))17 true_chimeric = set()18 true_not_chimeric = set()19 for read in SeqIO.parse(args["chimeric"], "fasta"):20 if "chimeric" in read.id:21 true_chimeric.add(read.id)22 else:23 true_not_chimeric.add(read.id)24 all_read = true_chimeric | true_not_chimeric25 positif_notcov = set()26 positif_chimeric = set()27 for row in csv.reader(args["yacrd"], delimiter="\t"):28 if row[0] == "Not_covered":29 positif_notcov.add(row[1])30 if row[0] == "Chimeric":31 positif_chimeric.add(row[1])32 negatif = all_read - positif_chimeric33 34 P = len(true_chimeric)35 N = len(true_not_chimeric)36 FN = len(true_chimeric & negatif)37 TN = len(true_not_chimeric & negatif)38 TP = len(true_chimeric & positif_chimeric)39 FP = len(true_not_chimeric & positif_chimeric)40 print("positif", len(true_chimeric))41 print("negatif", len(true_not_chimeric))42 try:43 print("precision : {:.2%}".format(TP / (TP + FP)))44 except ZeroDivisionError:45 print("can't compute precision TP: {} (TP + FP): {}".format(TP, TP + FP))46 47 try:48 print("sensitivity : {:.2%}".format(TP / P))49 except ZeroDivisionError:50 print("can't compute sensitivity TP: {} P: {}".format(TP, P))51 52 try:53 print("specificity : {:.2%}".format(TN / N))54 except ZeroDivisionError:55 print("can't compute specificity TN: {} N: {}".format(TN, N))56if __name__ == "__main__":...
blah.py
Source:blah.py
1def dostuff():2 print('hi')3def notcov():...
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!!