File: myfunctions.py

package info (click to toggle)
seqmagick 0.8.6-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,560 kB
  • sloc: python: 3,232; makefile: 120; sh: 39
file content (19 lines) | stat: -rw-r--r-- 483 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
"""
A collection of functions to apply
"""
import hashlib

def no_gaps(records):
    for record in records:
        if not '-' in str(record.seq):
            yield record

def hash_starts_numeric(records):
    """
    Very useful function that only accepts records with a numeric start to
    their sha-1 hash.
    """
    for record in records:
        seq_hash = hashlib.sha1(str(record.seq).encode('utf-8')).hexdigest()
        if seq_hash[0].isdigit():
            yield record