<commit_before>#!/usr/bin/python

import argparse
import sys
import datetime
import os
from collections import OrderedDict
import json
import base64

import pybedtools
import pysam
import vcf

import fasta_utils


mydir = os.path.dirname(os.path.realpath(__file__))
vcf_template = os.path.join(mydir, "resources/template.vcf")


def convert_metasv_bed_to_vcf(bedfile=None, vcf_out=None, vcf_template_file=vcf_template, sample=None, reference=None, pass_calls=True):
    vcf_template_reader = vcf.Reader(open(vcf_template_file, "r"))

    # The following are hacks to ensure sample name and contig names are put in the VCF header
    vcf_template_reader.samples = [sample]
    if reference:
        contigs = fasta_utils.get_contigs(reference)
        vcf_template_reader.contigs = OrderedDict([(contig.name, (contig.name, contig.length)) for contig in contigs])
        vcf_template_reader.metadata["reference"] = reference
        vcf_template_reader.metadata["fileDate"] = str(datetime.date.today())
        vcf_template_reader.metadata["source"] = [" ".join(sys.argv)]

    vcf_writer = vcf.Writer(open(vcf_out, "w"), vcf_template_reader)

    for interval in pybedtools.BedTool(bedfile):
        chrom = interval.chrom
        pos = interval.start
        end = interval.end

        sub_names = interval.name.split(":")
        sub_lengths = map(lambda x: int(x.split(",")[2]), sub_names)

        sub_types = map(lambda x: x.split(",")[0], sub_names)
        sub_methods = [name.split(",")[3] for name in sub_names]
        svmethods = (";".join([name.split(",")[3] for name in sub_names])).split(";")
        try:
            info = json.loads(base64.b64decode(name.split(",")[0]))
        except TypeError:
            info = dict()
        if len(interval.fields) > 9:
            info.update(json.loads(base64.b64decode(interval.fields[9])))

        index_to_use = 0<commit_msg>wrong positional<commit_after>#!/usr/bin/python

import argparse
import sys
import datetime
import os
from collections import OrderedDict
import json
import base64

import pybedtools
import pysam
import vcf

import fasta_utils


mydir = os.path.dirname(os.path.realpath(__file__))
vcf_template = os.path.join(mydir, "resources/template.vcf")


def convert_metasv_bed_to_vcf(bedfile=None, vcf_out=None, vcf_template_file=vcf_template, sample=None, reference=None, pass_calls=True):
    vcf_template_reader = vcf.Reader(open(vcf_template_file, "r"))

    # The following are hacks to ensure sample name and contig names are put in the VCF header
    vcf_template_reader.samples = [sample]
    if reference:
        contigs = fasta_utils.get_contigs(reference)
        vcf_template_reader.contigs = OrderedDict([(contig.name, (contig.name, contig.length)) for contig in contigs])
        vcf_template_reader.metadata["reference"] = reference
        vcf_template_reader.metadata["fileDate"] = str(datetime.date.today())
        vcf_template_reader.metadata["source"] = [" ".join(sys.argv)]

    vcf_writer = vcf.Writer(open(vcf_out, "w"), vcf_template_reader)

    for interval in pybedtools.BedTool(bedfile):
        chrom = interval.chrom
        pos = interval.start
        end = interval.end

        sub_names = interval.name.split(":")
        sub_lengths = map(lambda x: int(x.split(",")[2]), sub_names)

        sub_types = map(lambda x: x.split(",")[1], sub_names)
        sub_methods = [name.split(",")[3] for name in sub_names]
        svmethods = (";".join([name.split(",")[3] for name in sub_names])).split(";")
        try:
            info = json.loads(base64.b64decode(name.split(",")[0]))
        except TypeError:
            info = dict()
        if len(interval.fields) > 9:
            info.update(json.loads(base64.b64decode(interval.fields[9])))

        index_to_use = 0
{'fraction_non_alphanumeric': 0.12536366040729965, 'fraction_numerical': 0.009521290663845543, 'mean_word_length': 3.6461916461916464, 'pattern_counts': {'":': 2, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2985462', 'n_tokens_mistral': 1270, 'n_tokens_neox': 1225, 'n_words': 256}