Skip to content

Commit

Permalink
have updated numpy and pandas to specify correct float and int to sat…
Browse files Browse the repository at this point in the history
…isfy deprication of .int and .float
  • Loading branch information
Acribbs committed Apr 1, 2024
1 parent e8e6dd3 commit 0077438
Show file tree
Hide file tree
Showing 9 changed files with 34 additions and 34 deletions.
16 changes: 8 additions & 8 deletions cgat/BamTools/bamtools.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -666,12 +666,12 @@ def bam2stats_count(AlignmentFile samfile,
counter.total_read2_is_unmapped = total_read2_is_unmapped
counter.total_read2_is_missing = total_read2_is_missing

substitution_rates = numpy.zeros(fastq_nreads, dtype=numpy.float)
insertion_rates = numpy.zeros(fastq_nreads, dtype=numpy.float)
deletion_rates = numpy.zeros(fastq_nreads, dtype=numpy.float)
error_rates = numpy.zeros(fastq_nreads, dtype=numpy.float)
coverages = numpy.zeros(fastq_nreads, dtype=numpy.float)
mask = numpy.ones(fastq_nreads, dtype=numpy.int)
substitution_rates = numpy.zeros(fastq_nreads, dtype=numpy.float64)
insertion_rates = numpy.zeros(fastq_nreads, dtype=numpy.float64)
deletion_rates = numpy.zeros(fastq_nreads, dtype=numpy.float64)
error_rates = numpy.zeros(fastq_nreads, dtype=numpy.float64)
coverages = numpy.zeros(fastq_nreads, dtype=numpy.float64)
mask = numpy.ones(fastq_nreads, dtype=numpy.int64)

if outfile_details:
header = ["read_md5",
Expand Down Expand Up @@ -1558,7 +1558,7 @@ def bam2stats_window_count(AlignmentFile samfile,
cdef uint32_t ncontigs = len(contigs)
cdef int ncolumns = len(columns)
cdef numpy.ndarray offsets = numpy.zeros(
ncontigs + 1, dtype=numpy.int32)
ncontigs + 1, dtype=numpy.int64)

for idx, length in enumerate(lengths):
offsets[idx] = offset
Expand All @@ -1570,7 +1570,7 @@ def bam2stats_window_count(AlignmentFile samfile,

cdef numpy.ndarray window_counts = numpy.zeros(
(total_windows, ncolumns),
dtype=numpy.int32)
dtype=numpy.int64)

cdef int32_t [:, :] window_counts_view = window_counts

Expand Down
6 changes: 3 additions & 3 deletions cgat/BamTools/peakshape.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ cdef class Counter:
**kwargs )

nbins = len(bins) - 1
hist = numpy.zeros(nbins, dtype=numpy.int)
hist = numpy.zeros(nbins, dtype=numpy.int64)
cdef int lcounts = len(counts)

if self.smooth_method is not None:
Expand Down Expand Up @@ -196,7 +196,7 @@ cdef class Counter:
#################################################
# compute histogram
nbins = len(bins) - 1
hist = numpy.zeros(nbins, dtype = numpy.int)
hist = numpy.zeros(nbins, dtype = numpy.int64)

# decide in which region to count - interval or window
if use_interval:
Expand Down Expand Up @@ -337,7 +337,7 @@ cdef class CounterBam(Counter):
for i from rstart <= i < rend: ccounts[i] += 1

# transfer to numpy count object
counts = numpy.zeros( interval_width, dtype = numpy.int )
counts = numpy.zeros( interval_width, dtype = numpy.int64)
for i from 0 <= i < interval_width: counts[i] = ccounts[i]

free( ccounts )
Expand Down
24 changes: 12 additions & 12 deletions cgat/GeneModelAnalysis.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -307,9 +307,9 @@ class Counter:
return utr5, utr3

cimport numpy
DTYPE_INT = numpy.int
DTYPE_INT = numpy.int64
ctypedef numpy.int_t DTYPE_INT_t
DTYPE_FLOAT = numpy.float
DTYPE_FLOAT = numpy.float64
ctypedef numpy.float_t DTYPE_FLOAT_t


Expand Down Expand Up @@ -360,8 +360,8 @@ class CounterReadCoverage(Counter):
return

cdef int length = sum( [x[1] - x[0] for x in segments ] )
cdef numpy.ndarray[DTYPE_INT_t, ndim=1] counts_sense = numpy.zeros( length, dtype = numpy.int )
cdef numpy.ndarray[DTYPE_INT_t, ndim=1] counts_antisense = numpy.zeros( length, dtype = numpy.int )
cdef numpy.ndarray[DTYPE_INT_t, ndim=1] counts_sense = numpy.zeros( length, dtype = numpy.int64)
cdef numpy.ndarray[DTYPE_INT_t, ndim=1] counts_antisense = numpy.zeros( length, dtype = numpy.int64)
cdef int p, pos, offset

reads_sense, reads_antisense = set(), set()
Expand Down Expand Up @@ -893,11 +893,11 @@ class CounterReadCountsFull(CounterBAM):
x=ndirection_status,
y=nexons_status,
z=nspliced_status):
counters = numpy.zeros(n, dtype=numpy.float)
counters = numpy.zeros(n, dtype=numpy.float64)
counters.shape = (x,y,z)
return counters

# counters = numpy.zeros(ncounters, dtype=numpy.float)
# counters = numpy.zeros(ncounters, dtype=numpy.float64)
# counters.shape = (ndirection_status,
# nexons_status,
# nspliced_status)
Expand Down Expand Up @@ -1072,7 +1072,7 @@ class CounterReadCountsFull(CounterBAM):

if not weight_multi_mapping:
# convert to full counts
counters = numpy.array(counters, dtype=numpy.int)
counters = numpy.array(counters, dtype=numpy.int64)

self.counters = counters
self.reads_below_quality = quality_read_status
Expand Down Expand Up @@ -1415,7 +1415,7 @@ class CounterReadPairCountsFull(CounterBAM):
cdef AlignedSegment read1

# define counters, add 1 for quality filtered reads
counters = numpy.zeros(ncounters, dtype=numpy.float)
counters = numpy.zeros(ncounters, dtype=numpy.float64)
counters.shape = (npair_status,
ndirection_status,
nexons_status,
Expand Down Expand Up @@ -1667,7 +1667,7 @@ class CounterReadPairCountsFull(CounterBAM):

if not weight_multi_mapping:
# convert to full counts
counters = numpy.array(counters, dtype=numpy.int)
counters = numpy.array(counters, dtype=numpy.int64)

self.counters = counters

Expand Down Expand Up @@ -2308,7 +2308,7 @@ class CounterCoverage(CounterOverlap):

l = sum([x[1] - x[0] for x in segments])

counts = numpy.zeros(l, numpy.int)
counts = numpy.zeros(l, numpy.int64)

intervals = set()
if contig in self.mIntersectors:
Expand Down Expand Up @@ -4864,8 +4864,8 @@ class CounterReadExtension(Counter):
# create dummy counts vector
start, end = 0, 1

counts.append([numpy.zeros(end - start, numpy.int),
numpy.zeros(end - start, numpy.int)])
counts.append([numpy.zeros(end - start, numpy.int64),
numpy.zeros(end - start, numpy.int64)])

def __add(counts, positions, offset):
l = len(counts)
Expand Down
2 changes: 1 addition & 1 deletion cgat/Genomics.py
Original file line number Diff line number Diff line change
Expand Up @@ -1475,7 +1475,7 @@ def AlignedPair2SubstitutionMatrix(seq1, seq2, alphabet):
raise ValueError("two sequences of unequal length submitted")

nchars = len(alphabet)
matrix = numpy.zeros((nchars, nchars), numpy.int)
matrix = numpy.zeros((nchars, nchars), numpy.int64)

map_char2pos = {}
for x in alphabet:
Expand Down
6 changes: 3 additions & 3 deletions cgat/MatrixTools.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ def getMatrixFromEdges(lines, options,
return matrix


def buildMatrixFromLists(lists, dtype=numpy.float, default=None):
def buildMatrixFromLists(lists, dtype=numpy.float64, default=None):
'''build a matrix from a list of lists.
Each list is a list of tuples (row, value).
Expand All @@ -235,7 +235,7 @@ def buildMatrixFromLists(lists, dtype=numpy.float, default=None):
return matrix, list(all_rows.keys())


def buildMatrixFromTables(infiles, column, column_header=0, dtype=numpy.float,
def buildMatrixFromTables(infiles, column, column_header=0, dtype=numpy.float64,
default=None):
'''build a matrix from a column called *column* in a series of input files.
Expand All @@ -260,7 +260,7 @@ def buildMatrixFromEdges(edges,
is_symmetric=False,
missing_value=0,
diagonal_value=0,
dtype=numpy.int):
dtype=numpy.int64):
"""build a matrix from an edge-list representation.
For example, the following list of tuples::
Expand Down
2 changes: 1 addition & 1 deletion cgat/SetTools.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def unionIntersectionMatrix(list_of_sets):
'''

l = len(list_of_sets)
matrix = numpy.zeros((l, l), dtype=numpy.int)
matrix = numpy.zeros((l, l), dtype=numpy.int64)
for x in range(l):
xx = list_of_sets[x]
for y in range(x):
Expand Down
6 changes: 3 additions & 3 deletions cgat/Stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -594,7 +594,7 @@ def doFDRPython(pvalues,
# v[i] = number of observations less than or equal to pvalue[i]
# could this be done more elegantly?
val2bin = len(bins) - numpy.digitize(pvalues, bins)
v = numpy.zeros(m, dtype=numpy.int)
v = numpy.zeros(m, dtype=numpy.int64)
lastbin = None
for x in range(m - 1, -1, -1):
bin = val2bin[idx[x]]
Expand Down Expand Up @@ -1155,8 +1155,8 @@ def savitzky_golay(y, window_size, order, deriv=0, rate=1):
"""

try:
window_size = numpy.abs(numpy.int(window_size))
order = numpy.abs(numpy.int(order))
window_size = numpy.abs(numpy.int64(window_size))
order = numpy.abs(numpy.int64(order))
except ValueError:
raise ValueError("window_size and order have to be of type int")
if window_size % 2 != 1 or window_size < 1:
Expand Down
4 changes: 2 additions & 2 deletions cgat/tools/diff_bed.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def _count(self, filename, idx):

nexons_overlapping += 1
start, end = this.start, this.end
counts = numpy.zeros(end - start, numpy.int)
counts = numpy.zeros(end - start, numpy.int64)
for other_start, other_end, other_value in intervals:
for x in range(max(start, other_start) - start, min(end, other_end) - start):
counts[x] += 1
Expand Down Expand Up @@ -203,7 +203,7 @@ def _countIndices(self, idx_in, idx):
continue

nexons_overlapping += 1
counts = numpy.zeros(end - start, numpy.int)
counts = numpy.zeros(end - start, numpy.int64)
for other_start, other_end, other_value in intervals:
for x in range(max(start, other_start) - start, min(end, other_end) - start):
counts[x] += 1
Expand Down
2 changes: 1 addition & 1 deletion cgat/tools/diff_gtf.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ def _count(self, filename, idx):
overlapping_genes.add(this.gene_id)
nexons_overlapping += 1
start, end = this.start, this.end
counts = numpy.zeros(end - start, numpy.int)
counts = numpy.zeros(end - start, numpy.int64)
for other_start, other_end, other_value in intervals:
for x in range(max(start, other_start) - start, min(end, other_end) - start):
counts[x] += 1
Expand Down

0 comments on commit 0077438

Please sign in to comment.