fasta.sizes
Written by Lucas Sinclair. MIT Licensed. Contact at www.sinclair.bio
1#!/usr/bin/env python3 2# -*- coding: utf-8 -*- 3 4""" 5Written by Lucas Sinclair. 6MIT Licensed. 7Contact at www.sinclair.bio 8""" 9 10# Built-in modules # 11import re 12 13# Internal modules # 14from fasta import FASTA 15from plumbing.cache import property_cached 16 17############################################################################### 18class SizesFASTA(FASTA): 19 """A FASTA file with size annotation affecting the count.""" 20 21 @property_cached 22 def count(self): 23 get_size = lambda x: int(re.findall("size=([0-9]+)", x)[0]) 24 sizes = (get_size(r.description) for r in self) 25 return sum(sizes) 26 27 def add_str(self, seq, name=None, size=1, desc=""): 28 """Use this method to add a sequence as a string to this fasta.""" 29 from Bio.SeqRecord import SeqRecord 30 from Bio.Seq import Seq 31 self.add_seq(SeqRecord(Seq(seq), id=name + ';size=%i;' % size, description=desc))
19class SizesFASTA(FASTA): 20 """A FASTA file with size annotation affecting the count.""" 21 22 @property_cached 23 def count(self): 24 get_size = lambda x: int(re.findall("size=([0-9]+)", x)[0]) 25 sizes = (get_size(r.description) for r in self) 26 return sum(sizes) 27 28 def add_str(self, seq, name=None, size=1, desc=""): 29 """Use this method to add a sequence as a string to this fasta.""" 30 from Bio.SeqRecord import SeqRecord 31 from Bio.Seq import Seq 32 self.add_seq(SeqRecord(Seq(seq), id=name + ';size=%i;' % size, description=desc))
A FASTA file with size annotation affecting the count.
def
add_str(self, seq, name=None, size=1, desc=''):
28 def add_str(self, seq, name=None, size=1, desc=""): 29 """Use this method to add a sequence as a string to this fasta.""" 30 from Bio.SeqRecord import SeqRecord 31 from Bio.Seq import Seq 32 self.add_seq(SeqRecord(Seq(seq), id=name + ';size=%i;' % size, description=desc))
Use this method to add a sequence as a string to this fasta.
Inherited Members
- autopaths.base_path.BasePath
- BasePath
- clean_path
- path
- short_prefix
- extension
- escaped
- absolute_path
- physical_path
- relative_path
- rel_path_from
- exists
- is_symlink
- permissions
- mdate
- mdate_iso
- cdate
- cdate_iso
- unix_style
- wsl_style
- win_style
- with_tilda
- with_home
- link_from
- link_to
- symlinks_on_linux
- symlinks_on_windows
- hard_link_win_to
- fasta.core.FASTA
- format
- ext
- buffer_size
- gzipped
- first
- lengths
- lengths_counter
- open
- close
- parse
- progress
- create
- add
- add_seq
- add_fasta
- add_fastas
- flush
- write
- compress
- compress_slow
- compress_fast
- ids
- get_id
- sequences
- sql
- length_by_id
- subsample
- rename_with_num
- rename_with_prefix
- rename_sequences
- extract_length
- extract_sequences
- remove_trailing_stars
- remove_duplicates
- convert_U_to_T
- align
- template_align
- index_bowtie
- index_samtools
- graphs
- parse_primers
- autopaths.file_path.FilePath
- prefix_path
- prefix
- name
- filename
- directory
- count_bytes
- size
- contents
- contents_utf8
- md5
- might_be_binary
- contains_binary
- magic_number
- lines
- read
- touch
- writelines
- remove
- copy
- execute
- replace_extension
- new_name_insert
- make_directory
- must_exist
- head
- pretty_head
- tail
- pretty_tail
- move_to
- rename
- gzip_to
- gzip_internal
- gzip_external
- gzip_pigz
- ungzip_to
- ungzip_internal
- ungzip_external
- zip_to
- unzip_to
- untar_to
- untargz_to
- untargz_to_internal
- untargz_to_external
- append
- prepend
- remove_line
- remove_first_line
- replace_line
- replace_word
- sed_replace
- builtins.str
- encode
- replace
- split
- rsplit
- join
- capitalize
- casefold
- title
- center
- expandtabs
- find
- partition
- index
- ljust
- lower
- lstrip
- rfind
- rindex
- rjust
- rstrip
- rpartition
- splitlines
- strip
- swapcase
- translate
- upper
- startswith
- endswith
- removeprefix
- removesuffix
- isascii
- islower
- isupper
- istitle
- isspace
- isdecimal
- isdigit
- isnumeric
- isalpha
- isalnum
- isidentifier
- isprintable
- zfill
- format_map
- maketrans