diff options
| author | Jon Bernard <bernardj@gmail.com> | 2010-10-26 22:20:28 -0400 |
|---|---|---|
| committer | Jon Bernard <bernardj@gmail.com> | 2010-10-26 22:20:28 -0400 |
| commit | 3a38b0738a45e417a2ab6b3b0d53e82daf965a10 (patch) | |
| tree | e7770f394fe2e4bb2fc41fa317c4c8073c5affb6 | |
| parent | 55b32df671c330e5a041a1d2da0ac0f20db9d74d (diff) | |
| download | pepseq-3a38b0738a45e417a2ab6b3b0d53e82daf965a10.zip | |
Add lysine branching
| -rw-r--r-- | pepseq/amino_acid.py | 91 |
1 files changed, 56 insertions, 35 deletions
diff --git a/pepseq/amino_acid.py b/pepseq/amino_acid.py index 5b7bb5c..05ecb07 100644 --- a/pepseq/amino_acid.py +++ b/pepseq/amino_acid.py @@ -6,26 +6,28 @@ class AminoAcid(object): """ Amino acids are molecules containing an amine group, a carboxylic acid group and a side chain that varies between different amino acids. """ - aminoAcids = {'G': ('Glycine', 'Gly', 57.05), - 'A': ('Alanine', 'Ala', 71.09), - 'S': ('Serine', 'Ser', 87.08), - 'T': ('Threonine', 'Thr', 101.11), - 'C': ('Cysteine', 'Cys', 103.15), - 'V': ('Valine', 'Val', 99.14), - 'L': ('Leucine', 'Leu', 113.16), - 'I': ('Isoleucine', 'Ile', 113.16), - 'M': ('Methionine', 'Met', 131.19), - 'P': ('Proline', 'Pro', 97.12), - 'F': ('Phenylalanine', 'Phe', 147.18), - 'Y': ('Tyrosine', 'Tyr', 163.18), - 'W': ('Tryptophan', 'Trp', 186.21), - 'D': ('Aspartic Acid', 'Asp', 115.09), - 'E': ('Glutamic Acid', 'Glu', 129.12), - 'N': ('Asparagine', 'Asn', 114.11), - 'Q': ('Glutamine', 'Gln', 128.14), - 'H': ('Histidine', 'His', 137.14), - 'K': ('Lysine', 'Lys', 128.17), - 'R': ('Arginine', 'Arg', 156.19)} + aminoAcids = {'G': ('Glycine', 'Gly', 57.05), + 'A': ('Alanine', 'Ala', 71.09), + 'S': ('Serine', 'Ser', 87.08), + 'T': ('Threonine', 'Thr', 101.11), + 'C': ('Cysteine', 'Cys', 103.15), + 'V': ('Valine', 'Val', 99.14), + 'L': ('Leucine', 'Leu', 113.16), + 'I': ('Isoleucine', 'Ile', 113.16), + 'M': ('Methionine', 'Met', 131.19), + 'P': ('Proline', 'Pro', 97.12), + 'F': ('Phenylalanine', 'Phe', 147.18), + 'Y': ('Tyrosine', 'Tyr', 163.18), + 'W': ('Tryptophan', 'Trp', 186.21), + 'D': ('Aspartic Acid', 'Asp', 115.09), + 'E': ('Glutamic Acid', 'Glu', 129.12), + 'N': ('Asparagine', 'Asn', 114.11), + 'Q': ('Glutamine', 'Gln', 128.14), + 'H': ('Histidine', 'His', 137.14), + 'K': ('Lysine', 'Lys', 128.17), + 'R': ('Arginine', 'Arg', 156.19), + 'B': ('Borono Phenylalanine', 'Bpa', 309.08), + } def __init__(self, letter): self.letter = letter.upper() @@ -41,38 +43,57 @@ class AminoAcid(object): class Peptide(object): def __init__(self, amino_acids): + self.amino_acids = amino_acids self.weight = 0 self.string = "" - self.amino_acids = amino_acids - for amino_acid in self.amino_acids: + for amino_acid in amino_acids: self.weight += amino_acid.weight - self.string += ('%s' % (amino_acid.letter.lower())) - if amino_acid is not self.amino_acids[-1]: - self.string += ',' + self.string += ('%s' % (amino_acid.letter)) + + def branch_before(self, index): + self.weight = 0 + for (counter, amino_acid) in enumerate(self.amino_acids): + if counter < index: + self.weight += 2 * amino_acid.weight + else: + self.weight += amino_acid.weight + self.string = '(' + self.string[0:index] + ')2' + self.string[index:] def __cmp__(self, other): return cmp(self.weight, other.weight) def __str__(self): - return "%d: %s" % (self.weight, self.string) + return self.string + if __name__ == '__main__': import itertools - fragment = ( - ((AminoAcid('a'), AminoAcid('t'), AminoAcid('k'))), - ((AminoAcid('r'), AminoAcid('q'), AminoAcid('h'))), - ((AminoAcid('r'), AminoAcid('q'), AminoAcid('h'))), - ((AminoAcid('r'), AminoAcid('q'), AminoAcid('h'))), - ((AminoAcid('r'), AminoAcid('q'), AminoAcid('h'))), + LOW = 2636.0 + HIGH = 2637.0 + + possibilities = ( + (AminoAcid('B'), AminoAcid('Q'), AminoAcid('T'), AminoAcid('Y')), + (AminoAcid('B'), AminoAcid('E'), AminoAcid('L'), AminoAcid('F')), + (AminoAcid('B'), AminoAcid('D'), AminoAcid('S'), AminoAcid('H')), + (AminoAcid('B'), AminoAcid('N'), AminoAcid('A'), AminoAcid('W')), + (AminoAcid('K'), AminoAcid('N')), + (AminoAcid('S'), AminoAcid('N'), AminoAcid('T'), AminoAcid('F')), + (AminoAcid('T'), AminoAcid('D'), AminoAcid('G'), AminoAcid('W')), + (AminoAcid('B'), AminoAcid('Q'), AminoAcid('P'), AminoAcid('H')), + (AminoAcid('L'), AminoAcid('E'), AminoAcid('A'), AminoAcid('Y')), ) peptides = [] - sequences = tuple(itertools.product(*fragment)) + sequences = tuple(itertools.product(*possibilities)) for sequence in sequences: - peptides.append(Peptide(sequence)) + if sequence[4].letter == 'K': + peptide = Peptide(sequence) + peptide.branch_before(4) + peptides.append(peptide) peptides.sort() for peptide in peptides: - print peptide + if peptide.weight > LOW and peptide.weight < HIGH: + print "%.2f %s" % (peptide.weight, peptide) |