@@ -0,0 +1,2048 @@
+#!/usr/bin/env python%0A%0Aimport argparse%0Afrom Bio import SeqIO%0Aimport sys%0A%0A# Pull specified sequences out of a fasta file.%0A#%0A# Matt Gitzendanner%0A# University of Florida%0A#%0A# get_seqs_from_fasta.py -i file.fa -o file.phy -s headers_of_sequences_to_get%0A#%0A%0A__version__= 1.0   #  June 25, 2020%0A%0Adef open_files(in_file, out):%0A    %22%22%22Opens the input and output files and returns file handles%22%22%22%0A    try:%0A        in_fh=open(in_file, 'r')%0A    except IOError:%0A        print (f%22Can't open file for reading: %7Bin_file%7D%22)%0A        sys.exit()%0A    try:%0A        out_fh=open(out, 'a')%0A    except IOError:%0A        print (f%22Can't open file for writing: %7Bout%7D%22)%0A        sys.exit()%0A    %0A    return in_fh, out_fh%0A%0Adef pull_seq(seqs_in, in_format, seqs_out, out_format, seq_list, verbose):%0A    %22%22%22Pulls specified sequences from a file and write to a new file%22%22%22%0A    for record in SeqIO.parse(seqs_in, in_format):%0A        if record.id in seq_list:%0A            if verbose:%0A                print(f%22Writing sequence for %7Brecord.id%7D%22)%0A%0A            SeqIO.write(record, seqs_out, out_format)%0A%0Adef main():%0A    parser = argparse.ArgumentParser(prog='get_seqs_from_fasta.py')%0A    parser.add_argument(%22-i%22, %22--in_file%22, help=%22input file%22)%0A    parser.add_argument(%22-f%22, %22--in_format%22, help=%22File format of input file.%22,%0A                        default='fasta')%0A    parser.add_argument(%22-o%22, %22--out_file%22, help=%22output file%22)%0A    parser.add_argument(%22-x%22, %22--out_format%22, help=%22File format of output file.%22,%0A                        default='fasta')%0A    parser.add_argument('-s', '--sequences', nargs='+', default=%5B%5D,%0A                         help=%22List of sequence IDs to keep%22)%0A    parser.add_argument('-v', '--verbose',action='store_true', default=False)%0A    parser.add_argument('--version', action='version', version=f'%25(prog)s  Version: %7B__version__%7D:')%0A%0A    args = parser.parse_args()%0A%0A    in_fh, out_fh = open_files(args.in_file, args.out_file)%0A%0A    pull_seq(in_fh, args.in_format, out_fh, args.out_format, args.sequences, args.verbose)%0A%0Aif __name__ == %22__main__%22:%0A    main()%0A%0A%0A%0A%09%09%0A

Add get_seq_from_fasta.py