text stringlengths 0 828 |
|---|
for line in openfile: |
if line[0] == '>': |
yield header, processSequences(sequences) |
header = processHeaderLine(line) |
sequences = list() |
else: |
sequences.append(line) |
#Yield last entry |
if sequences: |
yield header, processSequences(sequences)" |
1976,"def _extractFastaHeader(fastaHeader, parser=None, forceId=False): |
""""""Parses a fasta header and returns extracted information in a dictionary. |
Unless a custom parser is specified, a ``Pyteomics`` function is used, which |
provides parsers for the formats of UniProtKB, UniRef, UniParc and UniMES |
(UniProt Metagenomic and Environmental Sequences), described at |
`www.uniprot.org <http://www.uniprot.org/help/fasta-headers>_`. |
:param fastaHeader: str, protein entry header from a fasta file |
:param parser: is a function that takes a fastaHeader string and returns a |
dictionary, containing at least the key ""id"". If None the parser |
function from pyteomics ``pyteomics.fasta.parse()`` is used. |
:param forceId: bool, if True and no id can be extracted from the fasta |
header the whole header sequence is used as a protein id instead of |
raising an exception. |
:returns: dict, describing a fasta header |
"""""" |
if parser is None: |
try: |
headerInfo = pyteomics.fasta.parse(fastaHeader) |
except pyteomics.auxiliary.PyteomicsError as pyteomicsError: |
#If forceId is set True, it uses the whole header as an id |
if forceId: |
headerInfo = {'id': fastaHeader} |
else: |
raise pyteomicsError |
else: |
headerInfo = parser(fastaHeader) |
return headerInfo" |
1977,"def fastaParseSgd(header): |
""""""Custom parser for fasta headers in the SGD format, see |
www.yeastgenome.org. |
:param header: str, protein entry header from a fasta file |
:returns: dict, parsed header |
"""""" |
rePattern = '([\S]+)\s([\S]+).+(\"".+\"")' |
ID, name, description = re.match(rePattern, header).groups() |
info = {'id':ID, 'name':name, 'description':description} |
return info" |
1978,"def _reprJSON(self): |
""""""Returns a JSON serializable represenation of a ``PeptideSequence`` |
class instance. Use :func:`maspy.proteindb.PeptideSequence._fromJSON()` |
to generate a new ``PeptideSequence`` instance from the return value. |
:returns: a JSON serializable python object |
"""""" |
return {'__PepSeq__': [self.sequence, self.missedCleavage, |
self.isUnique, list(self.proteins), |
self.proteinPositions]}" |
1979,"def _fromJSON(cls, jsonobject): |
""""""Generates a new instance of :class:`maspy.proteindb.PeptideSequence` |
from a decoded JSON object (as generated by |
:func:`maspy.proteindb.PeptideSequence._reprJSON()`). |
:param jsonobject: decoded JSON object |
:returns: a new instance of :class:`PeptideSequence` |
"""""" |
newInstance = cls(jsonobject[0], jsonobject[1]) |
newInstance.isUnique = jsonobject[2] |
newInstance.proteins = set(jsonobject[3]) |
newInstance.proteinPositions = jsonobject[4] |
return newInstance" |
1980,"def _reprJSON(self): |
""""""Returns a JSON serializable represenation of a ``ProteinSequence`` |
class instance. Use :func:`maspy.proteindb.ProteinSequence._fromJSON()` |
to generate a new ``ProteinSequence`` instance from the return value. |
:returns: a JSON serializable python object |
"""""" |
jsonDict = self.__dict__ |
jsonDict['uniquePeptides'] = list(jsonDict['uniquePeptides']) |
jsonDict['sharedPeptides'] = list(jsonDict['sharedPeptides']) |
return {'__ProtSeq__': jsonDict}" |
1981,"def _fromJSON(cls, jsonobject): |
""""""Generates a new instance of :class:`maspy.proteindb.ProteinSequence` |
from a decoded JSON object (as generated by |
:func:`maspy.proteindb.ProteinSequence._reprJSON()`). |
:param jsonobject: decoded JSON object |
:returns: a new instance of :class:`ProteinSequence` |
"""""" |
newInstance = cls(None, None) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.