Last active
March 3, 2017 19:55
-
-
Save ShaiberAlon/b47b55c44e4799fe20bc2015d69a0dd1 to your computer and use it in GitHub Desktop.
script to get certain nucleotide from within a specific contig from a fasta file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import anvio.utils as u | |
import argparse | |
import sys | |
parser = argparse.ArgumentParser(description='Get nucleotides from fasta file beyween user defined nucleotide positions inside a specified contig') | |
parser.add_argument('-1','--N1',metavar='INT',dest='n1',type=int,help='Nucleotide sequence start position') | |
parser.add_argument('-2','--N2',metavar='INT',dest='n2',type=int,help='Nucleotide sequence start position') | |
parser.add_argument('-c','--contig',metavar='STRING',dest='c',help='Contig name') | |
parser.add_argument('-o','--out',metavar='FILE',dest='output',help='Output file') | |
parser.add_argument('-i','--input',metavar='FILE',dest='input',help='Input file') | |
args = parser.parse_args() | |
f = u.get_FASTA_file_as_dictionary(args.input) | |
with open(args.output,'w') as o: | |
o.write(">%s_nucleotide_range_%s_to_%s\n"%(args.c,args.n1,args.n2)) | |
o.write(f[args.c][args.n1:args.n2]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment