import pandas as pd import numpy as np Load the PWM pwmfile = 'sigma70-PWM.txt' pwmdf =…
- User
import pandas as pd import numpy as np
Load the PWM
pwm_file = 'sigma70-PWM.txt' pwm_df = pd.read_csv(pwm_file, sep='\t')
Read sequences to score
seq_file = '3548.csv' df = pd.read_csv(seq_file, delimiter=';', header=None) df['sequence'] = df[0].str.lower()
seq_length = len(pwm_df) output_file = '3548-weights.tsv'
with open(output_file, 'w') as out: out.write('sequence\tscore\n') for seq in df['sequence']: if len(seq) != seq_length: out.write(f"{seq}\tERROR: length mismatch\n") continue score = 0.0 # Initialize score (using sum instead of product) for i, nt in enumerate(seq): if nt not in 'acgt': score = float('-inf') # Use negative infinity for invalid nucleotides break score += pwm_df.loc[i, nt.upper()] # Add log-odds scores out.write(f"{seq}\t{score}\n")
print(f"PWM scores written to {output_file}")
Read file promoters_with_sequences.tsv, column PromoterSequence contains sequences. Calculate PWMs for all of them, some may be empty, skip them. Store scores in new column "PWM", save as "sigma70-promoters-pwm.txt"
Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.