<commit_before># VAPiD v0.9

# VAPiD is an extremely lightweight virus genome annotator that takes any number of viral genomes and annotates them
# producing files suitable for NCBI submission

import subprocess
import re
import argparse
import timeit
import os
from Bio.Seq import Seq
from Bio import SeqIO
from Bio.Blast import NCBIWWW
import platform
import sys
from Bio import Entrez
from Bio import pairwise2
import time
Entrez.email = '<EMAIL>'


VERSION = 'v0.9b'


# Reads in a fasta file that should have strain names for the names of the sequences -  can handle any number of
# sequences. Also strips leading and trailing Ns or ?s from the provided sequence. Returns a list with the names of the
# strains and the strings of the genomes
def read_fasta(fasta_file_loc):
    strain_list = []
    genome_list = []
    dna_string = ''

    for line in open(fasta_file_loc):
        if line[0] == '>':
            strain_list.append(line[1:].split()[0])
            if dna_string != '':
                # test commenting out to see if we handle incomplete sequences better this way
                #xip = 0
                #while dna_string[xip] == 'N' or dna_string[xip] == '?':
                #    xip += 1

                #y = len(dna_string)
                #while dna_string[y-1] == 'N' or dna_string[y-1] == '?':
                #    y -= 1

                #dna_string = dna_string[xip:y]

                genome_list.append(dna_string)
                dna_string = ''
        else:
            dna_string += line.strip()
    # new code, trying to fix certian erroneous alignments
    genome_list.append(dna_string.replace('U', 'T'))
    return strain_list, genome_list


# This function takes the strain name and a location of the individual fasta file we saved earlier and runs a blast
# Search saving the top 35 hits - then the top hit is found that is a complete genome and the fasta and .gbk of that
# are saved - then we run alignment on the two and return two strings one of them our sequence with '-' and the
# other of our new reference sequence
def blast_n_stuff(strain, our_fasta_loc):
    # If we've already done this one before skip the blasting step, speeds up error checking for development
    if not os.path.isfile(strain + SLASH + strain + '.blastresults'):
        print('Searching NCBI for the best reference sequence (may take longer for multiple requests due to NCBI '
              'throttling)')

        record = open(our_fasta_loc).read()

        result_handle = NCBIWWW.qblast('blastn', 'nt', record, word_size=28, descriptions=0, alignments=35,
                                       format_type='Text')
        with open(strain + SLASH + strain + '.blastresults', 'w') as out_handle:<commit_msg>made blast search only the virus database<commit_after># VAPiD v0.9

# VAPiD is an extremely lightweight virus genome annotator that takes any number of viral genomes and annotates them
# producing files suitable for NCBI submission

import subprocess
import re
import argparse
import timeit
import os
from Bio.Seq import Seq
from Bio import SeqIO
from Bio.Blast import NCBIWWW
import platform
import sys
from Bio import Entrez
from Bio import pairwise2
import time
Entrez.email = '<EMAIL>'


VERSION = 'v0.9b'


# Reads in a fasta file that should have strain names for the names of the sequences -  can handle any number of
# sequences. Also strips leading and trailing Ns or ?s from the provided sequence. Returns a list with the names of the
# strains and the strings of the genomes
def read_fasta(fasta_file_loc):
    strain_list = []
    genome_list = []
    dna_string = ''

    for line in open(fasta_file_loc):
        if line[0] == '>':
            strain_list.append(line[1:].split()[0])
            if dna_string != '':
                # test commenting out to see if we handle incomplete sequences better this way
                #xip = 0
                #while dna_string[xip] == 'N' or dna_string[xip] == '?':
                #    xip += 1

                #y = len(dna_string)
                #while dna_string[y-1] == 'N' or dna_string[y-1] == '?':
                #    y -= 1

                #dna_string = dna_string[xip:y]

                genome_list.append(dna_string)
                dna_string = ''
        else:
            dna_string += line.strip()
    # new code, trying to fix certian erroneous alignments
    genome_list.append(dna_string.replace('U', 'T'))
    return strain_list, genome_list


# This function takes the strain name and a location of the individual fasta file we saved earlier and runs a blast
# Search saving the top 35 hits - then the top hit is found that is a complete genome and the fasta and .gbk of that
# are saved - then we run alignment on the two and return two strings one of them our sequence with '-' and the
# other of our new reference sequence
def blast_n_stuff(strain, our_fasta_loc):
    # If we've already done this one before skip the blasting step, speeds up error checking for development
    if not os.path.isfile(strain + SLASH + strain + '.blastresults'):
        print('Searching NCBI for the best reference sequence (may take longer for multiple requests due to NCBI '
              'throttling)')

        record = open(our_fasta_loc).read()

        result_handle = NCBIWWW.qblast('blastn', 'nt', record, word_size=28, descriptions=0, alignments=35, entrez_query = 'txid10239[ORGN]',
                                       format_type='Text')
        with open(strain + SLASH + strain + '.blastresults', 'w') as out_handle:
{'fraction_non_alphanumeric': 0.07870036101083032, 'fraction_numerical': 0.008122743682310469, 'mean_word_length': 2.6841755319148937, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7258366', 'n_tokens_mistral': 1671, 'n_tokens_neox': 1545, 'n_words': 635}