This script converts a fasta file and a given fasta reference file to a file in VCF. A reference genome can be provided in fasta format as input. If no reference is given, the first sequence in the fasta file will be used as reference. """ import argparse import libPoMo.fasta as fa # noqa import libPoMo.vcf as vcf # noqa ver = "1.0" parser = argparse.ArgumentParser(prog="FastaToVCF.py", description="convert fasta to VCF;" + " script version" + ver) parser.add_argument("fastafile", help="path to fasta file") parser.add_argument("output", help="name of VCF output file") parser.add_argument("-r", "--reference", help="path to reference genome in fasta format") args = parser.parse_args() faSeq = fa.open_seq(args.fastafile) if args.reference is not None: faRef = fa.open_seq(args.reference) refSeq = faRef.get_seq_by_id(0) else: refSeq = faSeq.get_seq_by_id(0) fa.save_as_vcf(faSeq, refSeq, args.output)
a file in VCF. A reference genome can be provided in fasta format as input. If no reference is given, the first sequence in the fasta file will be used as reference. """ import argparse import libPoMo.fasta as fa # noqa import libPoMo.vcf as vcf # noqa ver = "1.0" parser = argparse.ArgumentParser(prog="FastaToVCF.py", description="convert fasta to VCF;" + " script version" + ver) parser.add_argument("fastafile", help="path to fasta file") parser.add_argument("output", help="name of VCF output file") parser.add_argument("-r", "--reference", help="path to reference genome in fasta format") args = parser.parse_args() faSeq = fa.open_seq(args.fastafile) if args.reference is not None: faRef = fa.open_seq(args.reference) refSeq = faRef.get_seq_by_id(0) else: refSeq = faSeq.get_seq_by_id(0) fa.save_as_vcf(faSeq, refSeq, args.output)
print("Read in test sequence ", test_sequence, '.', sep='') seq = fa.open_seq(test_sequence) print("Print sequence information.") seq.print_info() ###################################################################### print("\n##################################################") print("Test FaStream object.") faStr = fa.init_seq(test_sequence) faStr.print_info(maxB=None) while faStr.read_next_seq() is not None: faStr.print_info() faStr.close() ###################################################################### print("\n##################################################") test_sequence = "data/fasta-sample-wolfs.dat" ref_sequence = "data/fasta-reference-wolf.dat" fn = "vcf-test-tmp.dat" print("Compare ", test_sequence, " to ", ref_sequence, '.', sep='') faSeq = fa.open_seq(test_sequence) faRef = fa.open_seq(ref_sequence) refSeq = faRef.get_seq_by_id(0) fa.save_as_vcf(faSeq, refSeq, fn) with open(fn) as file: for line in file: print(line, end='') os.remove(fn)
print("\n##################################################") print("Read in test sequence ", test_sequence, '.', sep='') seq = fa.open_seq(test_sequence) print("Print sequence information.") seq.print_info() ###################################################################### print("\n##################################################") print("Test FaStream object.") faStr = fa.init_seq(test_sequence) faStr.print_info(maxB=None) while faStr.read_next_seq() is not None: faStr.print_info() faStr.close() ###################################################################### print("\n##################################################") test_sequence = "data/fasta-sample-wolfs.dat" ref_sequence = "data/fasta-reference-wolf.dat" fn = "vcf-test-tmp.dat" print("Compare ", test_sequence, " to ", ref_sequence, '.', sep='') faSeq = fa.open_seq(test_sequence) faRef = fa.open_seq(ref_sequence) refSeq = faRef.get_seq_by_id(0) fa.save_as_vcf(faSeq, refSeq, fn) with open(fn) as file: for line in file: print(line, end='') os.remove(fn)