Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def parse(self, spec: str, cmdline_type: str = 'back') -> Iterator[Adapter]:
"""
Parse an adapter specification and yield appropriate Adapter classes.
This works like the _parse_no_file() function above, but also supports the
``file:`` notation for reading adapters from an external FASTA
file. Since a file can contain multiple adapters, this
function is a generator.
"""
if spec.startswith('file:'):
# read adapter sequences from a file
with xopen(spec[5:], mode="rb", threads=0) as f:
fasta = FastaReader(f)
for record in fasta:
name = record.name.split(None, 1)
name = name[0] if name else None
yield self._parse(record.sequence, cmdline_type, name=name)
else:
yield self._parse(spec, cmdline_type, name=None)