How to use generate_variant_id method in avocado

Best Python code snippet using avocado_python

vcfgraph.py

Source:vcfgraph.py Github

copy

Full Screen

...54 "Reference intervals:", pformat(list(self.get_ref_alleles()))55 ]56 return "\n".join(s)57 @staticmethod58 def generate_variant_id(record, varIdCounts=None):59 """60 Generate a variant ID for a pySAM VCF record61 :param record: a pysam record62 :param varIdCounts: defaultdict dictionary of counts per variant ID:63 varIdCounts = defaultdict(int)64 :return: variant ID string65 """66 if record.id:67 varId = record.id68 if varIdCounts is not None:69 if varId in varIdCounts:70 raise Exception("Duplicated variant ID: {}".format(varId))71 varIdCounts[varId] = 172 else:73 varId = "{}:{}".format(record.chrom, record.pos)74 if varIdCounts is not None:75 varIdCounts[varId] += 176 varId = "{}-{}".format(varId, varIdCounts[varId])77 return varId78 @staticmethod79 def generate_allele_ids(record, varId):80 return [("{}:{}".format(varId, n), record.alleles[n]) for n in range(len(record.alleles))]81 @staticmethod82 def create_from_vcf(ref_file_name,83 vcf_file_name,84 ins_info_key,85 chrom=None, start=None, end=None,86 padding_length=150,87 allele_graph=False):88 """ Create a VCFGraph object from a VCF input file89 :param ref_file_name: Reference Fasta name90 :param vcf_file_name: VCF file name91 :param chrom: chromosome to read from92 :param start: start position for tabix / VCF fetch93 :param end: end position for tabix / VCF fetch94 :param padding_length: length of reference padding95 :param allele_graph: Create an allele graph, rather than haplotype graph96 :return: a VCFGraph97 """98 vcf = pysam.VariantFile(vcf_file_name)99 graph = VCFGraph(ref_file_name, chrom)100 varIdCounts = defaultdict(int)101 record_count = 0102 for record in vcf.fetch(chrom, start, end):103 logging.debug("Processing: %s", str(record).rstrip())104 if chrom is None:105 chrom = record.chrom106 graph.chrom = chrom107 elif chrom != record.chrom:108 break109 if graph.first_pos is None:110 graph.first_pos = record.pos111 if graph.last_pos is None or graph.last_pos < record.stop:112 graph.last_pos = record.stop113 varId = VCFGraph.generate_variant_id(record, varIdCounts)114 record_count += 1115 graph.add_record(record, allele_graph, varId, ins_info_key)116 if not record_count:117 raise NoVCFRecordsException("No VCF records found at {}:{}-{}".format(chrom, start, end))118 graph.add_ref_support(graph.first_pos - padding_length, graph.last_pos + padding_length)119 # Split read nodes for ALTs to link into (esp. for remote breakends)120 for be in graph.alts.values():121 if graph.first_pos <= be.end <= graph.last_pos:122 graph.refs.slice(be.end + 1)123 else:124 graph.add_ref_support(be.end + 1, be.end + padding_length)125 return graph126 def add_record(self, vcf, allele_graph, varId, ins_info_key):127 """ Add one vcfRecord to the graph...

Full Screen

Full Screen

varianter.py

Source:varianter.py Github

copy

Full Screen

...29 :param variant: Avocado test variant (list of TreeNode-like objects)30 :return: True when the variant does not contain (any useful) data31 """32 return not variant or variant == [tree.TreeNode()] * len(variant)33def generate_variant_id(variant):34 """35 Basic function to generate variant-id from a variant36 :param variant: Avocado test variant (list of TreeNode-like objects)37 :return: String compounded of ordered node names and a hash of all38 values.39 """40 def get_variant_name(variant):41 """42 To get the variant full name string43 :param variant: Avocado test variant (list of TreeNode-like objects)44 :return: Complete variant name string45 """46 full_name = []47 for node in variant:...

Full Screen

Full Screen

burden_test.py

Source:burden_test.py Github

copy

Full Screen

...32 for k, v in opencga_d.items():33 values = "\t".join([i for i in v])34 vid = k.replace("_", "\t")35 fout.write(f"{vid}\t{values}")36def generate_variant_id(*strings):37 """_summary_38 Returns:39 _type_: _description_40 """41 res = "_".join([str(i) for i in strings])42 return res43def get_vid_opencga(file: str, generate_vid=False) -> set:44 """_summary_45 Args:46 file (str): _description_47 Returns:48 set: _description_49 """50 df = pd.read_csv(file, sep="\t")51 if generate_variant_id:52 df["vid"] = df.apply(53 lambda row: generate_variant_id(54 row["chr"], row["pos"], row["ref"], row["alt"]55 ),56 axis=1,57 )58 return {i for i in df["vid"].tolist()}59def biomart_to_burden(file_path: str, outpath: str) -> None:60 """_summary_61 Args:62 file_path (str): _description_63 outpath (str): _description_64 """65 with open(file_path, "r") as fhand:66 next(fhand)67 lines = [i.strip() for i in fhand.readlines()]...

Full Screen

Full Screen

Automation Testing Tutorials

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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run avocado automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful