So I have a
usr/bin/python
from collections import defaultdict
import re, sys, random
from Bio import SeqI
- - - - - H E A D E R - - - - - - - - - - - - - - - - -
Objectives:
1. Read in a sequence
2. Find a specific segment of that sequence
3. Change a letter (mutation)
4. Output the sequence with the mutation
- - - - - U S E R V A R I A B L E S - - - - - - - -
mssg = " Search and Destroy"
genFile = 'P1.txt'
inFile = 'P1.txt'
inFolder = '.'
site = "" # what the mutation is
outFile = "Project1-Out.txt"
GenSeqs = defaultdict(lambda: "my own unknown" )
CT = defaultdict(lambda: 'nada')
GeneSeqs = defaultdict(lambda: 'nada')
CX = defaultdict(lambda: 0)
count = defaultdict(lambda: 0)
NTs = ['a', 't', 'g', 'c']
afreq = defaultdict(lambda: -1.1 )
tfreq = defaultdict(lambda: -1.1 )
gfreq = defaultdict(lambda: -1.1 )
cfreq = defaultdict(lambda: -1.1 )
seq = 'P1.txt'
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - M A I N - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
print("\n\n", mssg, ". . . . ")
IN1 = open( "P1.txt", 'r')
number = 1
for line in IN1:
if (re.match('>', line)):
header = line.rstrip() # remove right white space
else:
GenSeqs[header] = line.rstrip() # Dict[key] = value, key = header, value = sequence
number += 0
print("There are %d gene sequences in file %s" % (number, inFile))
for records in SeqIO.parse ('P1.txt','fasta'):
if 'a' in records.seq:
print (records)
To answer your question, you can use CRISPR.
I prefer CRISPR with vim bindings.
I'm a big fan of cRispr, crispy, and crispl
Format your code properly so we can easily read it and be more specific with your question and you'll get a lot more help.
I have tidied it a fair bit to how [I believe..] it should look
Now we need to figure out what the actual question is. So much for quick help...
It does not appear that you are searching for a pattern but replacing in a specific location. Do you need to use a python program for this (unless this is an assignment).