Untitled conversation
- User
import numpy as np import pandas as pd # --- Load PWM --- pwm_file = 'sigma70-PWM-10.txt' pwm_df = pd.read_csv(pwm_file, sep='\t') seq_length = len(pwm_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-rev.fasta' # Change to your file path if needed sequence = read_fasta(fasta_file) # --- Slide window and calculate PWM scores --- scores = [] for i in range(len(sequence) - seq_length + 1): window = sequence[i:i+seq_length] score = 0.0 for j, nt in enumerate(window): # Optionally, you can handle invalid characters as needed (e.g., skip window or assign a penalty). score += pwm_df.loc[j, nt.upper()] scores.append(score) scores = np.array(scores) # --- Save array to file --- np.save('sliding_scores.npy', scores) print(f"Saved {len(scores)} scores to sliding_scores.npy")I have file promoters_with_sequences.tsv. In column "PromoterSequence" are sequences of promoters. Slide PWM matrix over each of them like in the code above and find the highest scoring spot. Output the sequence and the score to two new columns, call them NewBest-10 and NewScore-10. Save the file as promoters_with_sequences-new.tsv
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.