text stringlengths 0 828 |
|---|
if proteinId not in proteindb.proteins: |
protein = ProteinSequence(proteinId, sequence) |
protein.name = proteinName |
protein.fastaHeader = header |
protein.fastaInfo = headerInfo |
proteindb.proteins[protein.id] = protein |
#Perform the insilico digestion |
_digestion = maspy.peptidemethods.digestInSilico(sequence, cleavageRule, |
missedCleavage, |
removeNtermM, |
minLength, maxLength |
) |
#Add peptides to the protein database |
for unmodPeptide, info in _digestion: |
if ignoreIsoleucine: |
unmodPeptideNoIsoleucine = unmodPeptide.replace('I', 'L') |
if unmodPeptideNoIsoleucine in proteindb.peptides: |
currPeptide = proteindb.peptides[unmodPeptideNoIsoleucine] |
else: |
currPeptide = PeptideSequence(unmodPeptideNoIsoleucine, |
mc=info['missedCleavage'] |
) |
proteindb.peptides[unmodPeptideNoIsoleucine] = currPeptide |
if unmodPeptide not in proteindb.peptides: |
proteindb.peptides[unmodPeptide] = currPeptide |
else: |
if unmodPeptide in proteindb.peptides: |
currPeptide = proteindb.peptides[unmodPeptide] |
else: |
currPeptide = PeptideSequence(unmodPeptide, |
mc=info['missedCleavage'] |
) |
proteindb.peptides[unmodPeptide] = currPeptide |
if proteinId not in currPeptide.proteins: |
currPeptide.proteins.add(proteinId) |
#TODO: change that a peptide can appear multiple times in a |
# protein sequence. |
currPeptide.proteinPositions[proteinId] = (info['startPos'], |
info['endPos'] |
) |
#Add peptide entries to the protein entries, define wheter a peptide can be |
#uniquely assigend to a single protein (.isUnique = True). |
for peptide, peptideEntry in viewitems(proteindb.peptides): |
numProteinMatches = len(peptideEntry.proteins) |
if numProteinMatches == 1: |
peptideEntry.isUnique = True |
elif numProteinMatches > 1: |
peptideEntry.isUnique = False |
else: |
raise Exception('No protein matches in proteindb for peptide' + |
'sequence: ' + peptide) |
for proteinId in peptideEntry.proteins: |
if peptideEntry.isUnique: |
proteindb.proteins[proteinId].uniquePeptides.add(peptide) |
else: |
proteindb.proteins[proteinId].sharedPeptides.add(peptide) |
#Check protein entries if the digestions generated at least one peptide that |
#is uniquely assigned to the protein (.isUnique = True) |
for proteinEntry in viewvalues(proteindb.proteins): |
if len(proteinEntry.uniquePeptides) > 0: |
proteinEntry.isUnique = True |
else: |
proteinEntry.isUnique = False |
#Note: TODO, altough isoleucin is ignored, the protein entry should only |
#show the actually present ILE / LEU occurence, not any possibilities |
return proteindb" |
1975,"def _readFastaFile(filepath): |
""""""Read a FASTA file and yields tuples of 'header' and 'sequence' entries. |
:param filepath: file path of the FASTA file |
:yields: FASTA entries in the format ('header', 'sequence'). |
The 'header' string does not contain the '>' and trailing white spaces. |
The 'sequence' string does not contain trailing white spaces, a '*' at |
the end of the sequence is removed. |
See also :func:`importProteinDatabase` and |
:func:`maspy.peptidemethods.digestInSilico`. |
"""""" |
processSequences = lambda i: ''.join([s.rstrip() for s in i]).rstrip('*') |
processHeaderLine = lambda line: line[1:].rstrip() |
with io.open(filepath) as openfile: |
#Iterate through lines until the first header is encountered |
try: |
line = next(openfile) |
while line[0] != '>': |
line = next(openfile) |
header = processHeaderLine(line) |
sequences = list() |
except StopIteration: |
errorText = 'File does not contain fasta entries.' |
raise maspy.errors.FileFormatError(errorText) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.