コード例 #1
0
ファイル: _predict.py プロジェクト: nlhepler/idepi
 def seqrecords():
     is_dna = ARGS.ENCODER == DNAEncoder
     seq_fmt = seqfile_format(ARGS.SEQUENCES)
     source = Verifier(SeqIO.parse(seq_fh, seq_fmt), DNAAlphabet)
     try:
         for record in source:
             yield record if is_dna else translate(record)
     except VerifyError:
         if is_dna:
             msg = (
                 "your model specifies a DNA encoding "
                 "which is incompatible with protein sequences"
                 )
             raise RuntimeError(msg)
         source.set_alphabet(AminoAlphabet)
         for record in source:
             yield record
コード例 #2
0
ファイル: _predict.py プロジェクト: stevenweaver/idepi
 def seqrecords():
     is_dna = ARGS.ENCODER == DNAEncoder
     seq_fmt = seqfile_format(ARGS.SEQUENCES)
     source = Verifier(SeqIO.parse(seq_fh, seq_fmt), DNAAlphabet)
     try:
         for record in source:
             yield record if is_dna else translate(record)
     except VerifyError:
         if is_dna:
             msg = (
                 "your model specifies a DNA encoding "
                 "which is incompatible with protein sequences"
                 )
             raise RuntimeError(msg)
         source.set_alphabet(AminoAlphabet)
         for record in source:
             yield record
コード例 #3
0
ファイル: __init__.py プロジェクト: erikvolz/idepi-ev0
 def __call__(self, string):
     try:
         with open(string) as h:
             source = Verifier(SeqIO.parse(h, seqfile_format(string)), DNAAlphabet)
             try:
                 seq = next(iter(source))
                 if not self.is_dna:
                     seq = translate(seq)
             except VerifyError:
                 if self.is_dna:
                     raise ArgumentTypeError("DNA encoding incompatible with protein reference")
                 source.set_alphabet(AminoAlphabet)
                 seq = next(iter(source))
         return seq
     except ArgumentTypeError:
         raise sys.exc_info()[1]
     except:
         raise ArgumentTypeError("invalid FASTA file '{0:s}'".format(string))
コード例 #4
0
 def __call__(self, string):
     try:
         with open(string) as h:
             source = Verifier(SeqIO.parse(h, seqfile_format(string)),
                               DNAAlphabet)
             try:
                 seq = next(iter(source))
                 if not self.is_dna:
                     seq = translate(seq)
             except VerifyError:
                 if self.is_dna:
                     raise ArgumentTypeError(
                         "DNA encoding incompatible with protein reference")
                 source.set_alphabet(AminoAlphabet)
                 seq = next(iter(source))
         return seq
     except ArgumentTypeError:
         raise sys.exc_info()[1]
     except:
         raise ArgumentTypeError(
             "invalid FASTA file '{0:s}'".format(string))