Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
PyFastANI
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Martin Larralde
PyFastANI
Commits
c9c49411
Commit
c9c49411
authored
3 years ago
by
Martin Larralde
Browse files
Options
Downloads
Patches
Plain Diff
Fix some Cython warnings in `pyfastani/__init__.pyx`
parent
b7250862
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
pyfastani/_fastani.pyx
+31
-37
31 additions, 37 deletions
pyfastani/_fastani.pyx
with
31 additions
and
37 deletions
pyfastani/_fastani.pyx
+
31
−
37
View file @
c9c49411
# coding: utf-8
# cython: language_level=3, linetrace=True, language=cpp
# cython: language_level=3, linetrace=True, language=cpp
, binding=False
"""
Bindings to FastANI, a method for fast whole-genome similarity estimation.
"""
...
...
@@ -193,9 +193,9 @@ cdef class Sketch:
"""
assert
self
.
_sk
!=
nullptr
cdef
object
contig
cdef
const
unsigned
char
[::
1
]
seq
cdef
kseq_t
kseq
cdef
ContigInfo_t
info
cdef
size_t
seql_total
=
0
cdef
Parameters_t
*
param
=
&
self
.
_param
...
...
@@ -216,13 +216,6 @@ cdef class Sketch:
# get a memory view of the sequence
seq
=
contig
# store the contig name and size
# (we just use the same name for all contigs)
# <-- actually useless, only useful for reporting
# info.name = string(name)
# info.len = seq.shape[0]
# self._sk.metadata.push_back(info)
# check the sequence is large enough to compute minimizers
if
seq
.
shape
[
0
]
>=
param
.
windowSize
and
seq
.
shape
[
0
]
>=
param
.
kmerSize
:
with
nogil
:
...
...
@@ -391,8 +384,7 @@ cdef class Mapper:
@staticmethod
cdef
void
_query_fragment
(
int
i
,
seqno_t
seq_counter
,
seqno_t
seq_counter
,
const
unsigned
char
[::
1
]
seq
,
int
min_read_length
,
Map_t
*
map
,
...
...
@@ -418,19 +410,21 @@ cdef class Mapper:
assert
self
.
_sk
!=
nullptr
cdef
int
i
# fragment counter
cdef
kseq_t
kseq
#
cdef
kseq_t
kseq
cdef
Map_t
*
map
cdef
MappingResultsVector_t
final_mappings
cdef
vector
[
CGI_Results
]
results
cdef
CGI_Results
result
cdef
object
contig
cdef
const
unsigned
char
[::
1
]
seq
cdef
uint64_t
seql
cdef
int
fragment_count
=
0
cdef
int
seq_counter
=
0
cdef
uint64_t
seql
=
0
cdef
uint64_t
min_length
cdef
uint64_t
shared_length
cdef
int
fragment_count
cdef
uint64_t
total_fragments
=
0
cdef
Parameters_t
p
=
self
.
_param
cdef
list
hits
=
[]
cdef
ofstream
out
=
ofstream
()
cdef
ofstream
out
# create a new mapper with the given mapping result vector
map
=
new
Map_t
(
p
,
self
.
_sk
[
0
],
total_fragments
,
0
)
...
...
@@ -473,37 +467,37 @@ cdef class Mapper:
# record the number of fragments
total_fragments
+=
fragment_count
else
:
fragmentCount
=
0
warnings
.
warn
(
UserWarning
,
(
"
Mapper received a short sequence relative to parameters,
"
"
mapping will not be computed.
"
))
# compute core genomic identity after successful mapping
computeCGI
(
p
,
final_mappings
,
map
[
0
],
self
.
_sk
[
0
],
total_fragments
,
# total query fragments
0
,
# queryFileNo, only used for visualization, ignored
string
(),
# fileName, only used for reporting, ignored
results
,
)
with
nogil
:
computeCGI
(
p
,
final_mappings
,
map
[
0
],
self
.
_sk
[
0
],
total_fragments
,
# total query fragments
0
,
# queryFileNo, only used for visualization, ignored
string
(),
# fileName, only used for reporting, ignored
results
,
)
# free the map
del
map
# build and return the list of hits
for
res
in
results
:
assert
res
.
refGenomeId
<
self
.
_lengths
.
size
()
assert
res
.
refGenomeId
<
len
(
self
.
_names
)
min_length
=
min
(
seql
,
self
.
_lengths
[
res
.
refGenomeId
])
shared_length
=
res
.
countSeq
*
p
.
minReadLength
for
res
ult
in
results
:
assert
res
ult
.
refGenomeId
<
self
.
_lengths
.
size
()
assert
res
ult
.
refGenomeId
<
len
(
self
.
_names
)
min_length
=
min
(
seql
,
self
.
_lengths
[
res
ult
.
refGenomeId
])
shared_length
=
res
ult
.
countSeq
*
p
.
minReadLength
if
shared_length
>=
min_length
*
p
.
minFraction
:
hits
.
append
(
Hit
(
name
=
self
.
_names
[
res
.
refGenomeId
],
identity
=
res
.
identity
,
matches
=
res
.
countSeq
,
fragments
=
res
.
totalQueryFragments
,
name
=
self
.
_names
[
res
ult
.
refGenomeId
],
identity
=
res
ult
.
identity
,
matches
=
res
ult
.
countSeq
,
fragments
=
res
ult
.
totalQueryFragments
,
))
return
hits
...
...
@@ -580,7 +574,7 @@ cdef class Hit:
self
.
identity
=
identity
def
__repr__
(
self
):
ty
=
type
(
self
).
__name__
cdef
str
ty
=
type
(
self
).
__name__
return
"
{}(name={!r}, identity={!r} matches={!r}, fragments={!r})
"
.
format
(
ty
,
self
.
name
,
self
.
identity
,
self
.
matches
,
self
.
fragments
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment