# Path: vdb/upload.py
# def upload(self, preview=False, **kwargs):
#     '''
#     format virus information, then upload to database
#     '''
#     self.connect(**kwargs)
#     print("Uploading Viruses to VDB")
#     viruses, sequences = self.parse(**kwargs)
#     print('Formatting documents for upload')
#     self.format_viruses(viruses, **kwargs)
#     self.format_sequences(sequences, **kwargs)
#     print("")
#     print("Filtering out viruses")
#     viruses = self.filter(viruses, 'strain', **kwargs)
#     print("Filtering out sequences")
#     sequences = self.filter(sequences, 'accession', **kwargs)
#     print("")
#     #self.match_duplicate_strains(viruses, sequences, **kwargs)
#     #self.match_database_duplicate_strains(viruses, sequences, **kwargs)
#     #self.match_duplicate_accessions(sequences, **kwargs)
#     #self.match_database_duplicate_accessions(sequences, **kwargs)
#     self.link_viruses_to_sequences(viruses, sequences)
#     #self.transfer_fields(viruses, sequences, self.virus_to_sequence_transfer_fields)
#     print("")
#     print("Upload Step")
#     if not preview:
#         print("Uploading viruses to " + self.database + "." + self.viruses_table)
#         self.upload_documents(self.viruses_table, viruses, index='strain', **kwargs)
#         print("Uploading sequences to " + self.database + "." + self.sequences_table)
#         self.upload_documents(self.sequences_table, sequences, index='accession', **kwargs)
#     else:
#         print("Viruses:")
#         print(json.dumps(viruses[0], indent=1))
#         print("Sequences:")
#         print(json.dumps(sequences[0], indent=1))
#         print("Remove \"--preview\" to upload documents")
#         print("Printed preview of viruses to be uploaded to make sure fields make sense")
# 
# Path: vdb/upload.py
# def get_parser():
#     parser = argparse.ArgumentParser()
#     parser.add_argument('-db', '--database', default='vdb', help="database to upload to")
#     parser.add_argument('--rethink_host', default=None, help="rethink host url")
#     parser.add_argument('--auth_key', default=None, help="auth_key for rethink database")
#     parser.add_argument('--local', default=False, action="store_true",  help ="connect to local instance of rethinkdb database")
#     parser.add_argument('-v', '--virus', help="virus name")
#     parser.add_argument('--fname', help="input file name")
#     parser.add_argument('--ftype', default='fasta', help="input file format, default \"fasta\", other is \"genbank\", \"accession\" or \"tsv\"")
#     parser.add_argument('--fasta_header_fix', default=None, help="faster header fix file. Default: None.")
#     parser.add_argument('--path', default="data/", help="path to fasta file, default is \"data/\"")
#     parser.add_argument('--accessions', default=None, help="comma seperated list of accessions to be uploaded")
#     parser.add_argument('--email', default=None, help="email to access NCBI database via entrez to get virus information")
#     parser.add_argument('--overwrite', default=False, action="store_true",  help ="Overwrite fields that are not none")
#     parser.add_argument('--preview', default=False, action="store_true",  help ="If included, preview a virus document to be uploaded")
#     parser.add_argument('--replace', default=False, action="store_true",  help ="If included, delete all documents in table")
# 
#     parser.add_argument('--source', default=None, help="source of fasta file")
#     parser.add_argument('--locus', default=None, help="gene or genomic region for sequences")
#     parser.add_argument('--host', default='human', help="host virus isolated from")
#     parser.add_argument('--country', default=None, help="country virus isolated from")
#     parser.add_argument('--authors', default=None, help="authors of source of sequences")
#     parser.add_argument('--title', default=None, help="title of sequence release")
#     parser.add_argument('--url', default=None, help="url of source of sequences")
#     parser.add_argument('--public', default=True, dest='public', action="store_true",  help ="sequences classified as public")
#     parser.add_argument('--private', default=False, dest='public', action="store_false",  help ="sequences classified as private")
#     return parser


import os, re, time, datetime, csv, sys, json
import numpy as np
            import glob
        import pandas
from rethinkdb import r
from Bio import SeqIO
from Bio import AlignIO
from unidecode import unidecode
from vdb.upload import upload
from vdb.upload import get_parser
            from Bio.Seq import Seq
            from Bio.SeqRecord import SeqRecord
            from Bio.Alphabet import IUPAC
            from Bio import AlignIO
sys.path.append('')  # need to import from base

parser = get_parser()
parser.add_argument('--upload_directory', default=False, action="store_true", help='upload all xls and fasta files in directory')
parser.add_argument('--vtype', default=None, help="type of virus, if applicable")
parser.add_argument('--subtype', default=None, help="subtype of virus")
parser.add_argument('--lineage', default=None, help="lineage of virus")


# Path: vdb/upload.py
# def upload(self, preview=False, **kwargs):
#     '''
#     format virus information, then upload to database
#     '''
#     self.connect(**kwargs)
#     print("Uploading Viruses to VDB")
#     viruses, sequences = self.parse(**kwargs)
#     print('Formatting documents for upload')
#     self.format_viruses(viruses, **kwargs)
#     self.format_sequences(sequences, **kwargs)
#     print("")
#     print("Filtering out viruses")
#     viruses = self.filter(viruses, 'strain', **kwargs)
#     print("Filtering out sequences")
#     sequences = self.filter(sequences, 'accession', **kwargs)
#     print("")
#     #self.match_duplicate_strains(viruses, sequences, **kwargs)
#     #self.match_database_duplicate_strains(viruses, sequences, **kwargs)
#     #self.match_duplicate_accessions(sequences, **kwargs)
#     #self.match_database_duplicate_accessions(sequences, **kwargs)
#     self.link_viruses_to_sequences(viruses, sequences)
#     #self.transfer_fields(viruses, sequences, self.virus_to_sequence_transfer_fields)
#     print("")
#     print("Upload Step")
#     if not preview:
#         print("Uploading viruses to " + self.database + "." + self.viruses_table)
#         self.upload_documents(self.viruses_table, viruses, index='strain', **kwargs)
#         print("Uploading sequences to " + self.database + "." + self.sequences_table)
#         self.upload_documents(self.sequences_table, sequences, index='accession', **kwargs)
#     else:
#         print("Viruses:")
#         print(json.dumps(viruses[0], indent=1))
#         print("Sequences:")
#         print(json.dumps(sequences[0], indent=1))
#         print("Remove \"--preview\" to upload documents")
#         print("Printed preview of viruses to be uploaded to make sure fields make sense")
# 
# Path: vdb/upload.py
# def get_parser():
#     parser = argparse.ArgumentParser()
#     parser.add_argument('-db', '--database', default='vdb', help="database to upload to")
#     parser.add_argument('--rethink_host', default=None, help="rethink host url")
#     parser.add_argument('--auth_key', default=None, help="auth_key for rethink database")
#     parser.add_argument('--local', default=False, action="store_true",  help ="connect to local instance of rethinkdb database")
#     parser.add_argument('-v', '--virus', help="virus name")
#     parser.add_argument('--fname', help="input file name")
#     parser.add_argument('--ftype', default='fasta', help="input file format, default \"fasta\", other is \"genbank\", \"accession\" or \"tsv\"")
#     parser.add_argument('--fasta_header_fix', default=None, help="faster header fix file. Default: None.")
#     parser.add_argument('--path', default="data/", help="path to fasta file, default is \"data/\"")
#     parser.add_argument('--accessions', default=None, help="comma seperated list of accessions to be uploaded")
#     parser.add_argument('--email', default=None, help="email to access NCBI database via entrez to get virus information")
#     parser.add_argument('--overwrite', default=False, action="store_true",  help ="Overwrite fields that are not none")
#     parser.add_argument('--preview', default=False, action="store_true",  help ="If included, preview a virus document to be uploaded")
#     parser.add_argument('--replace', default=False, action="store_true",  help ="If included, delete all documents in table")
# 
#     parser.add_argument('--source', default=None, help="source of fasta file")
#     parser.add_argument('--locus', default=None, help="gene or genomic region for sequences")
#     parser.add_argument('--host', default='human', help="host virus isolated from")
#     parser.add_argument('--country', default=None, help="country virus isolated from")
#     parser.add_argument('--authors', default=None, help="authors of source of sequences")
#     parser.add_argument('--title', default=None, help="title of sequence release")
#     parser.add_argument('--url', default=None, help="url of source of sequences")
#     parser.add_argument('--public', default=True, dest='public', action="store_true",  help ="sequences classified as public")
#     parser.add_argument('--private', default=False, dest='public', action="store_false",  help ="sequences classified as private")
#     return parser


# Path: vdb/flu_upload.py
import os, re, time, datetime, csv, sys, json
import numpy as np
            import glob
        import pandas
from rethinkdb import r
from Bio import SeqIO
from Bio import AlignIO
from unidecode import unidecode
from vdb.upload import upload
from vdb.upload import get_parser
            from Bio.Seq import Seq
            from Bio.SeqRecord import SeqRecord
            from Bio.Alphabet import IUPAC
            from Bio import AlignIO

sys.path.append('')  # need to import from base

parser = get_parser()
parser.add_argument('--upload_directory', default=False, action="store_true", help='upload all xls and fasta files in directory')
parser.add_argument('--vtype', default=None, help="type of virus, if applicable")
parser.add_argument('--subtype', default=None, help="subtype of virus")
parser.add_argument('--lineage', default=None, help="lineage of virus")


class flu_upload(upload):