File: parsers.py

package info (click to toggle)
idseq-bench 0.0~git20200902.8241a9a-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 196 kB
  • sloc: python: 849; sh: 39; makefile: 3
file content (15 lines) | stat: -rw-r--r-- 428 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
import re

FAST_FILE_TYPE = r"\.(?:fast|f)(?P<type>q|a)(?:\.|$)"

def extract_accession_id(raw_line):
  try:
    return re.search(r'^[@>](.+?\.\d+)', raw_line).group(1)
  except AttributeError:
    return None

def extract_fast_file_type_from_path(file_path):
  matches = re.findall(FAST_FILE_TYPE, file_path)
  if not matches:
    raise AttributeError(f"Unable to detect fast file type for '{file_path}'")
  return matches[-1]