Skip to content

Commit

Permalink
improve BlastRow constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
Donaim committed Jun 5, 2023
1 parent 845db4a commit bbbc8c4
Showing 1 changed file with 23 additions and 23 deletions.
46 changes: 23 additions & 23 deletions intact/intact.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,36 +84,36 @@ class BlastRow:
stitle: str
sstrand: str


def init_blast_row(row):
it = iter(row)
return BlastRow(
qseqid=next(it),
qlen=int(next(it)),
sseqid=next(it),
sgi=next(it),
slen=int(next(it)),
qstart=int(next(it)),
qend=int(next(it)),
sstart=int(next(it)),
send=int(next(it)),
evalue=float(next(it)),
bitscore=float(next(it)),
length=int(next(it)),
pident=float(next(it)),
nident=float(next(it)),
btop=next(it),
stitle=next(it),
sstrand=next(it),
)
@staticmethod
def init(row):
it = iter(row)
return BlastRow(
qseqid=next(it),
qlen=int(next(it)),
sseqid=next(it),
sgi=next(it),
slen=int(next(it)),
qstart=int(next(it)),
qend=int(next(it)),
sstart=int(next(it)),
send=int(next(it)),
evalue=float(next(it)),
bitscore=float(next(it)),
length=int(next(it)),
pident=float(next(it)),
nident=float(next(it)),
btop=next(it),
stitle=next(it),
sstrand=next(it),
)

def iterate_blast_rows_from_tsv(file_path):
previous_key = None
values = []

for row in iterate_values_from_tsv(file_path):
key = row[0]
typed = init_blast_row(row)
typed = BlastRow.make(row)

if key != previous_key and previous_key is not None:
yield values
Expand Down

0 comments on commit bbbc8c4

Please sign in to comment.