fastseqio 0.0.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- fastseqio-0.0.1/PKG-INFO +6 -0
- fastseqio-0.0.1/setup.cfg +4 -0
- fastseqio-0.0.1/setup.py +12 -0
- fastseqio-0.0.1/src/fastseqio.egg-info/PKG-INFO +6 -0
- fastseqio-0.0.1/src/fastseqio.egg-info/SOURCES.txt +8 -0
- fastseqio-0.0.1/src/fastseqio.egg-info/dependency_links.txt +1 -0
- fastseqio-0.0.1/src/fastseqio.egg-info/top_level.txt +2 -0
- fastseqio-0.0.1/src/seqio/__init__.py +7 -0
- fastseqio-0.0.1/src/seqio/_seqio.py +89 -0
- fastseqio-0.0.1/src/seqio/lib/_seqio.cpython-311-x86_64-linux-gnu.so +0 -0
fastseqio-0.0.1/PKG-INFO
ADDED
fastseqio-0.0.1/setup.py
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import setuptools
|
|
2
|
+
|
|
3
|
+
setuptools.setup(
|
|
4
|
+
name="fastseqio",
|
|
5
|
+
version="0.0.1",
|
|
6
|
+
author="dwpeng",
|
|
7
|
+
author_email="1732889554@qq.com",
|
|
8
|
+
description="A package for reading and writing fasta/fastq files",
|
|
9
|
+
packages=setuptools.find_namespace_packages(where="src"),
|
|
10
|
+
package_dir={"": "src"},
|
|
11
|
+
package_data={"seqio": ["lib/*.so", "lib/*.dylib", "lib/*.dll"]},
|
|
12
|
+
)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
from .lib._seqio import (
|
|
2
|
+
seqioFile as _seqioFile,
|
|
3
|
+
seqOpenMode as _seqOpenMode,
|
|
4
|
+
seqioRecord as _seqioRecord,
|
|
5
|
+
)
|
|
6
|
+
from typing import Optional
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class seqioOpenMode:
|
|
10
|
+
READ = _seqOpenMode.READ
|
|
11
|
+
WRITE = _seqOpenMode.WRITE
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class seqioRecord:
|
|
15
|
+
def __init__(
|
|
16
|
+
self,
|
|
17
|
+
name: str,
|
|
18
|
+
sequence: str,
|
|
19
|
+
quality: Optional[str] = None,
|
|
20
|
+
comment: Optional[str] = None,
|
|
21
|
+
):
|
|
22
|
+
self.__record = None
|
|
23
|
+
self.__length = len(sequence)
|
|
24
|
+
self.name = name
|
|
25
|
+
self.sequence = sequence
|
|
26
|
+
self.quality = quality
|
|
27
|
+
self.comment = comment
|
|
28
|
+
|
|
29
|
+
@classmethod
|
|
30
|
+
def fromRecord(cls, record: _seqioRecord):
|
|
31
|
+
self = cls(record.name, record.sequence, record.quality, record.comment)
|
|
32
|
+
self.__record = record
|
|
33
|
+
self.__length = record.length()
|
|
34
|
+
return self
|
|
35
|
+
|
|
36
|
+
def length(self):
|
|
37
|
+
return self.__length
|
|
38
|
+
|
|
39
|
+
def upper(self):
|
|
40
|
+
if self.__record is not None:
|
|
41
|
+
self.sequence = self.__record.upper()
|
|
42
|
+
else:
|
|
43
|
+
self.sequence = self.sequence.upper()
|
|
44
|
+
return self
|
|
45
|
+
|
|
46
|
+
def lower(self):
|
|
47
|
+
if self.__record is not None:
|
|
48
|
+
self.sequence = self.__record.lower()
|
|
49
|
+
else:
|
|
50
|
+
self.sequence = self.sequence.lower()
|
|
51
|
+
return self
|
|
52
|
+
|
|
53
|
+
def __str__(self):
|
|
54
|
+
return f"seqioRecord(name={self.name})"
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
class seqioFile:
|
|
58
|
+
def __init__(
|
|
59
|
+
self,
|
|
60
|
+
path: str,
|
|
61
|
+
mode: seqioOpenMode = seqioOpenMode.READ,
|
|
62
|
+
compressed: bool = False,
|
|
63
|
+
):
|
|
64
|
+
self.__file = _seqioFile(path, mode, compressed)
|
|
65
|
+
|
|
66
|
+
def readOne(self):
|
|
67
|
+
record = self.__file.readOne()
|
|
68
|
+
if record is None:
|
|
69
|
+
return None
|
|
70
|
+
return seqioRecord.fromRecord(record)
|
|
71
|
+
|
|
72
|
+
def readFasta(self):
|
|
73
|
+
record = self.__file.readFasta()
|
|
74
|
+
if record is None:
|
|
75
|
+
return None
|
|
76
|
+
return seqioRecord.fromRecord(record)
|
|
77
|
+
|
|
78
|
+
def readFastq(self):
|
|
79
|
+
record = self.__file.readFastq()
|
|
80
|
+
if record is None:
|
|
81
|
+
return None
|
|
82
|
+
return seqioRecord.fromRecord(record)
|
|
83
|
+
|
|
84
|
+
def __iter__(self):
|
|
85
|
+
while True:
|
|
86
|
+
record = self.__file.readOne()
|
|
87
|
+
if record is None:
|
|
88
|
+
break
|
|
89
|
+
yield seqioRecord.fromRecord(record)
|
|
Binary file
|