File size: 1,109 Bytes
6d3b444 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
"""
Debug script to analyze pI calculation differences.
"""
import os
import sys
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from Bio.SeqUtils.ProtParam import ProteinAnalysis
from modules.validate_sequences import SequenceValidator
def debug_sequence(sequence: str):
print(f"\nAnalyzing sequence: {sequence}")
# Our implementation
validator = SequenceValidator(sequence)
our_pi = validator.calculate_properties()['pI']
# BioPython's implementation
biopython = ProteinAnalysis(sequence)
bio_pi = round(biopython.isoelectric_point(), 2)
print(f"Our pI: {our_pi}")
print(f"BioPython pI: {bio_pi}")
# Print charge values at various pH levels
print("\npH\tOur Charge\tBioPython Charge")
print("-" * 40)
for ph in [2.0, 3.0, 4.0, 4.05, 4.1, 5.0, 6.0, 7.0]:
our_charge = validator.charge_at_ph(ph)
print(f"{ph:.2f}\t{our_charge:.3f}\t\t{our_charge:.3f}")
if __name__ == '__main__':
sequence = 'DDDEEEDDDEEE' # The acidic sequence that's causing issues
debug_sequence(sequence) |