Untitled conversation
- User
import numpy as np import pandas as pd # --- Load PPM --- ppm_file = 'sigma70-PPM-35.txt' ppm_df = pd.read_csv(ppm_file, sep='\t') seq_length = len(ppm_df) # --- Load FASTA sequence --- def read_fasta(filename): seq = [] with open(filename) as f: for line in f: if line.startswith('>'): continue seq.append(line.strip()) return ''.join(seq).lower() fasta_file = 'sega007.fasta' # Change to your file sequence = read_fasta(fasta_file) # --- Slide window and calculate probabilities --- probs = [] for i in range(len(sequence) - seq_length + 1): window = sequence[i:i+seq_length] prob = 1.0 for j, nt in enumerate(window): prob *= ppm_df.loc[j, nt.upper()] probs.append(prob) probs = np.array(probs) # --- Save array to file --- np.save('sliding_probs.npy', probs) print(f"Saved {len(probs)} probabilities to sliding_probs.npy")Can you make this program use PWM instead of PPM too?
- Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.