query stringlengths 9 9.05k | document stringlengths 10 222k | metadata dict | negatives listlengths 30 30 | negative_scores listlengths 30 30 | document_score stringlengths 4 10 | document_rank stringclasses 2
values |
|---|---|---|---|---|---|---|
(DivideAndConquer, list of items) > integer Return the number of inversion in the input list. | def get_number_of_inversions_naive(self, lst):
# Running time: O(n ** 2)
count_inv = 0
for i in range(len(lst)):
for j in range(i+1, len(lst)):
if lst[i] > lst[j]:
count_inv += 1
return count_inv | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sort_and_count(list):\n\t\n\tnum_inversions = 0\n \n\t# Checks for base case conditions\n\tif len(list) == 1:\n\t\treturn 0\n\tif len(list) == 2:\n\t\tif(list[0] > list[1]):\n\t\t\ttmp = list[0]\n\t\t\tlist[0] = list[1]\n\t\t\tlist[1] = tmp\n\t\t\treturn 1\n\t\telse:\n\t\t\treturn 0\n \n\t# Split list in... | [
"0.7062515",
"0.69687295",
"0.66037196",
"0.6344167",
"0.6119877",
"0.6117131",
"0.6082302",
"0.59911436",
"0.5978218",
"0.5976799",
"0.59311444",
"0.5852709",
"0.5825104",
"0.5798115",
"0.5738328",
"0.571564",
"0.5677115",
"0.56569874",
"0.56256956",
"0.55440384",
"0.5520918... | 0.6993015 | 1 |
(DivideAndConquer, list of items) > list of items, integer Return sorted (nondecreasing order) list and number of inversion in the unsorted list. | def sort_and_get_number_of_inversions(self, lst):
n = len(lst)
if n == 1: return lst, 0
mid = int(n / 2)
first_half_lst = lst[0:mid]
second_half_lst = lst[mid:n]
sorted_lst_a, inv_a = self.sort_and_get_number_of_inversions(first_half_lst)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sort_and_count(list):\n\t\n\tnum_inversions = 0\n \n\t# Checks for base case conditions\n\tif len(list) == 1:\n\t\treturn 0\n\tif len(list) == 2:\n\t\tif(list[0] > list[1]):\n\t\t\ttmp = list[0]\n\t\t\tlist[0] = list[1]\n\t\t\tlist[1] = tmp\n\t\t\treturn 1\n\t\telse:\n\t\t\treturn 0\n \n\t# Split list in... | [
"0.6966766",
"0.6634307",
"0.63370353",
"0.6168137",
"0.61555487",
"0.61466897",
"0.61388755",
"0.6133609",
"0.6067309",
"0.60362864",
"0.6008943",
"0.59136945",
"0.5850518",
"0.57970124",
"0.57707596",
"0.57702744",
"0.5769481",
"0.57642174",
"0.57587403",
"0.56971604",
"0.5... | 0.6911239 | 1 |
(DivideAndConquer, list of items, list of items) > list of items, integer Return a merged list of items from the two given sorted lists, and the number of cross inversions. | def merge_and_get_number_of_inversions(self, sorted_lst_a, sorted_lst_b):
a, b, cross_inv_count, out_lst = 0, 0, 0, []
while a < len(sorted_lst_a) and b < len(sorted_lst_b):
next_ = min(sorted_lst_a[a], sorted_lst_b[b])
out_lst.append(next_)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sort_and_get_number_of_inversions(self, lst):\r\n n = len(lst)\r\n if n == 1: return lst, 0 \r\n \r\n mid = int(n / 2)\r\n first_half_lst = lst[0:mid]\r\n second_half_lst = lst[mid:n]\r\n \r\n sorted_lst_a, inv_a = self.sort_and_get_number_of_inversions(f... | [
"0.696534",
"0.68707615",
"0.6819757",
"0.6697977",
"0.66420996",
"0.6603775",
"0.6519826",
"0.6437374",
"0.6407263",
"0.6369798",
"0.63683414",
"0.6362578",
"0.6361603",
"0.6355681",
"0.6301591",
"0.62989867",
"0.62555957",
"0.62402076",
"0.6238761",
"0.62335396",
"0.6217382... | 0.7517095 | 0 |
(list of items) > integer Return the total number of inversions in the list. | def get_number_of_inversions_fast(self, lst):
[sorted_lst, number_of_inversions] = self.sort_and_get_number_of_inversions(lst)
return number_of_inversions | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_number_of_inversions_naive(self, lst):\r\n # Running time: O(n ** 2)\r\n count_inv = 0\r\n \r\n for i in range(len(lst)):\r\n for j in range(i+1, len(lst)):\r\n if lst[i] > lst[j]:\r\n count_inv += 1\r\n \r\n ... | [
"0.76740617",
"0.69663835",
"0.68777406",
"0.6875091",
"0.670235",
"0.66490525",
"0.66405874",
"0.65164953",
"0.63821554",
"0.63685495",
"0.6352954",
"0.6159546",
"0.6088815",
"0.60537666",
"0.60520124",
"0.5987785",
"0.59610236",
"0.58229053",
"0.57834613",
"0.57777464",
"0.... | 0.7806225 | 0 |
(DivideAndConquer, list of numbers, list of numbers) > list of numbers Return the number of segments ([starts, ends]) that contains the given points. | def count_segments_naive(self, starts, ends, points):
count = [0] * len(points)
for i in range(len(points)):
for j in range(len(starts)):
if starts[j] <= points[i] <= ends[j]:
count[i] += 1
return count | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sort_and_count_segments(self, starts, ends, points):\r\n \r\n # Cons: needs lot of memeory space\r\n lst = []\r\n for i in range(len(starts)): \r\n lst.append(range(starts[i], ends[i]+1))\r\n \r\n # store all the items in list\r\n lst_2 = []\r\n ... | [
"0.76873475",
"0.6908779",
"0.6721834",
"0.63934237",
"0.63837194",
"0.63179475",
"0.6251489",
"0.6220081",
"0.6179521",
"0.6079581",
"0.6066167",
"0.6047114",
"0.6040338",
"0.602019",
"0.59992766",
"0.5991349",
"0.5951727",
"0.59492147",
"0.59482074",
"0.5928433",
"0.5899658... | 0.75870353 | 1 |
(DivideAndConquer, list of numbers, list of numbers) > list of numbers Return the number of segments ([starts, ends]) that contains the given points. | def sort_and_count_segments(self, starts, ends, points):
# Cons: needs lot of memeory space
lst = []
for i in range(len(starts)):
lst.append(range(starts[i], ends[i]+1))
# store all the items in list
lst_2 = []
for sublist in lst... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def count_segments_naive(self, starts, ends, points):\r\n count = [0] * len(points)\r\n \r\n for i in range(len(points)):\r\n for j in range(len(starts)):\r\n if starts[j] <= points[i] <= ends[j]:\r\n count[i] += 1\r\n \r\n ... | [
"0.7586944",
"0.69092137",
"0.6720667",
"0.6392025",
"0.63829225",
"0.6317457",
"0.6251013",
"0.6219915",
"0.61789197",
"0.60779417",
"0.60660803",
"0.60471064",
"0.60392404",
"0.6018971",
"0.60001427",
"0.5991444",
"0.59510916",
"0.59489214",
"0.5947792",
"0.59294945",
"0.58... | 0.7686965 | 0 |
The span of the genome covered by this interval, simply ``rightleft``. | def span(self) -> float | int:
return self.right - self.left | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def span(self):\n return self.right - self.left",
"def right(self):\n return self.left + self.width",
"def _rect_right(self):\n\treturn max(self.x, self.x + self.w)",
"def get_right(self):\n return self.right",
"def right(self):\n return self.points['topRight'].x",
"def right(... | [
"0.75360054",
"0.6977182",
"0.67229855",
"0.6658675",
"0.6636132",
"0.6636132",
"0.6634681",
"0.6588929",
"0.65714335",
"0.65182316",
"0.65182316",
"0.65107095",
"0.6496375",
"0.64313394",
"0.64235145",
"0.63681877",
"0.6348362",
"0.6321899",
"0.6303899",
"0.62718725",
"0.621... | 0.7066523 | 1 |
Returns True if this node is a sample. This value is derived from the ``flag`` variable. | def is_sample(self):
return self.flags & NODE_IS_SAMPLE | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def isSampleObject(self, object):\n return isinstance(object, Sample)",
"def should_sample(self):\n sampling_probability = 1.0 / self._trans_sample_rate\n log.debug(\"should_sample (sampling prob: %f)\", sampling_probability)\n\n return random() <= sampling_probability",
"def sample... | [
"0.672181",
"0.6518628",
"0.6260431",
"0.62490267",
"0.6131253",
"0.6130926",
"0.6098722",
"0.5927426",
"0.59075904",
"0.58247924",
"0.5785239",
"0.57314193",
"0.56839883",
"0.5620142",
"0.55811983",
"0.55382276",
"0.55382276",
"0.55382276",
"0.55382276",
"0.5444727",
"0.5442... | 0.84794223 | 0 |
Returns the span of this edge, i.e., the right position minus the left position | def span(self):
return self.right - self.left | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def span(self) -> float | int:\n return self.right - self.left",
"def right(self):\n return self.left + self.width",
"def get_rightmost_edge(self):\n return self.offset + sum(self.get_screen_widths())",
"def _rect_right(self):\n\treturn max(self.x, self.x + self.w)",
"def span(self):\r... | [
"0.81368136",
"0.701518",
"0.68822384",
"0.6815371",
"0.6714591",
"0.66649777",
"0.65827394",
"0.6555784",
"0.65373147",
"0.65056556",
"0.6468958",
"0.64179003",
"0.64179003",
"0.64132416",
"0.63606656",
"0.6330291",
"0.6309332",
"0.6306665",
"0.6282587",
"0.62755454",
"0.623... | 0.8796711 | 0 |
Return the set of all the alleles defined at this site | def alleles(self) -> set[str]:
return {self.ancestral_state} | {m.derived_state for m in self.mutations} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __all_Algs_ ( self ) :\n _algs = self.algorithms()\n\n algs = []\n for _a in _algs :\n algs += [ self.algorithm ( _a ) ]\n return algs",
"def __all_Algs_ ( self ) :\n _algs = self.algorithms()\n\n algs = []\n for _a in _algs :\n algs +=... | [
"0.642856",
"0.642856",
"0.630923",
"0.6286042",
"0.58750254",
"0.5865698",
"0.57211673",
"0.5679052",
"0.5674907",
"0.56577057",
"0.5641988",
"0.5608062",
"0.55561376",
"0.5552051",
"0.5543604",
"0.5485111",
"0.5471378",
"0.5470308",
"0.5417145",
"0.5412321",
"0.53868294",
... | 0.71627325 | 0 |
Returns the tree sequence that this tree is from. | def tree_sequence(self):
return self._tree_sequence | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sequence(self):\n return self._sequence",
"def sequence(self):\n return self._sequence",
"def seq(self):\n return self.__seq",
"def _get_sequence(self):\n return self.__sequence",
"def _get_sequence(self):\n return self.__sequence",
"def _get_sequence(self):\n return sel... | [
"0.71544707",
"0.71544707",
"0.7037959",
"0.69551474",
"0.69551474",
"0.69551474",
"0.69551474",
"0.69551474",
"0.69551474",
"0.69551474",
"0.69551474",
"0.69551474",
"0.69551474",
"0.69551474",
"0.69551474",
"0.69551474",
"0.69551474",
"0.69551474",
"0.69551474",
"0.69551474",... | 0.85810316 | 0 |
Seeks to the first tree in the sequence. This can be called whether the tree is in the null state or not. | def first(self):
self._ll_tree.first() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _subtree_first_position(self, p):\n walk = p\n while self.left(walk) is not None:\n walk = self.left(walk) # keep walking left\n return walk",
"def next(self):\n if self.tree:\n return self.tree.pop(0)\n else:\n return N... | [
"0.660314",
"0.64760095",
"0.6376602",
"0.6316613",
"0.6162586",
"0.6127605",
"0.59853953",
"0.5970342",
"0.5963031",
"0.5955081",
"0.59173644",
"0.59157276",
"0.5876437",
"0.5867431",
"0.5866775",
"0.5866372",
"0.58470535",
"0.5837272",
"0.5836598",
"0.58107615",
"0.5808733"... | 0.7007963 | 0 |
Seeks to the last tree in the sequence. This can be called whether the tree is in the null state or not. | def last(self):
self._ll_tree.last() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def next(self):\n if self.tree:\n return self.tree.pop(0)\n else:\n return None",
"def _last_node(self):\n if self.trail[-1][1] is None or self.trail[-1][1].group():\n return self.trail[-1][0]\n else:\n return self.trail[-2][0]",
"def _sub... | [
"0.67272776",
"0.6497329",
"0.6271991",
"0.62217784",
"0.61413",
"0.5913722",
"0.5874075",
"0.58652246",
"0.5858161",
"0.5857393",
"0.5756811",
"0.5713745",
"0.5711247",
"0.56995404",
"0.56981385",
"0.56921625",
"0.56867504",
"0.5683714",
"0.5659436",
"0.56540716",
"0.5630232... | 0.66392547 | 1 |
Sets the state to represent the tree at the specified index in the parent tree sequence. Negative indexes following the standard Python conventions are allowed, i.e., ``index=1`` will seek to the last tree in the sequence. | def seek_index(self, index):
num_trees = self.tree_sequence.num_trees
if index < 0:
index += num_trees
if index < 0 or index >= num_trees:
raise IndexError("Index out of bounds")
self._ll_tree.seek_index(index) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_parent(self, index):\n self.add_parent(self[index])",
"def index_tree(tree, offset):\n for idx, _ in enumerate(tree.leaves()):\n tree_location = tree.leaf_treeposition(idx)\n non_terminal = tree[tree_location[:-1]]\n # non_terminal.append(idx)\n non_terminal[0] = (no... | [
"0.75071144",
"0.61606544",
"0.61306906",
"0.610524",
"0.60673785",
"0.60346293",
"0.59761417",
"0.58896387",
"0.5853727",
"0.583221",
"0.58261275",
"0.58254135",
"0.5777877",
"0.5728535",
"0.57213974",
"0.5719348",
"0.56953764",
"0.56857836",
"0.5671511",
"0.56468385",
"0.56... | 0.73533607 | 1 |
Sets the state to represent the tree that covers the specified position in the parent tree sequence. After a successful return of this method we have ``tree.interval.left`` <= ``position`` < ``tree.interval.right``. | def seek(self, position):
if position < 0 or position >= self.tree_sequence.sequence_length:
raise ValueError("Position out of bounds")
self._ll_tree.seek(position) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def incorrectly_nested(self):\n return self.parent is not None and self.root < self.parent.root",
"def range(self, event):\r\n \r\n p = (event.x, self.toCartesian(event.y))\r\n \r\n if self.selectedRegion is None:\r\n self.selectedStart = Region(p[X],p[Y], p[X],p[Y... | [
"0.5189157",
"0.51179606",
"0.5026312",
"0.50189614",
"0.501893",
"0.50056726",
"0.49755922",
"0.49614823",
"0.4939759",
"0.49313232",
"0.48982006",
"0.4875646",
"0.4873501",
"0.48576027",
"0.48526996",
"0.48257813",
"0.48104724",
"0.48097932",
"0.48011398",
"0.47997323",
"0.... | 0.5324074 | 0 |
Produce the rank of this tree in the enumeration of all leaflabelled | def rank(self) -> tskit.Rank:
return combinatorics.RankTree.from_tsk_tree(self).rank() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rank(self, value):\n i = 0\n n = len(self._tree)\n rank = 0\n count = 0\n while i < n:\n cur = self._tree[i]\n if value < cur:\n i = 2 * i + 1\n continue\n elif value > cur:\n rank += self._counts[i... | [
"0.6719541",
"0.6719541",
"0.6709843",
"0.6597665",
"0.6596121",
"0.64263284",
"0.63351053",
"0.6324721",
"0.6302817",
"0.6271189",
"0.62567526",
"0.62199306",
"0.6192418",
"0.6187575",
"0.61534756",
"0.6153263",
"0.6145784",
"0.61232805",
"0.61212486",
"0.60855675",
"0.60677... | 0.70426434 | 0 |
Reconstruct the tree of the given ``rank`` | def unrank(num_leaves, rank, *, span=1, branch_length=1) -> Tree:
rank_tree = combinatorics.RankTree.unrank(num_leaves, rank)
return rank_tree.to_tsk_tree(span=span, branch_length=branch_length) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_rank(self,rank):\n self._rank = rank",
"def rank(self, rank):\n self._rank = rank",
"def unrank(self, rank, n):\n n, rank = as_int(n), as_int(rank)\n L = defaultdict(int)\n for i in range(n - 3, -1, -1):\n L[i] = rank % n\n rank = (rank - L[i])//... | [
"0.5881124",
"0.554703",
"0.5308001",
"0.52714247",
"0.5210244",
"0.5187636",
"0.5136379",
"0.51305073",
"0.511404",
"0.50770974",
"0.505568",
"0.50509405",
"0.5040395",
"0.5023109",
"0.4974609",
"0.49684256",
"0.49197778",
"0.48992774",
"0.48956037",
"0.48917592",
"0.4880511... | 0.6605275 | 0 |
Calculates the distribution of embedded topologies for every combination of the sample sets in ``sample_sets``. ``sample_sets`` defaults to all samples in the tree grouped by population. ``sample_sets`` need not include all samples but must be pairwise disjoint. | def count_topologies(self, sample_sets=None) -> tskit.TopologyCounter:
if sample_sets is None:
sample_sets = [
self.tree_sequence.samples(population=pop.id)
for pop in self.tree_sequence.populations()
]
return combinatorics.tree_count_topologies(s... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def count_topologies(self, sample_sets=None):\n if sample_sets is None:\n sample_sets = [\n self.samples(population=pop.id) for pop in self.populations()\n ]\n\n yield from combinatorics.treeseq_count_topologies(self, sample_sets)",
"def mean_descendants(self, s... | [
"0.6853211",
"0.5495889",
"0.53750056",
"0.5230435",
"0.52239096",
"0.5183111",
"0.51275563",
"0.5090824",
"0.507399",
"0.5047481",
"0.50104743",
"0.496506",
"0.4961381",
"0.49613678",
"0.49388197",
"0.4914775",
"0.49147126",
"0.48973826",
"0.48964328",
"0.48815396",
"0.48793... | 0.65130043 | 1 |
Returns the length of the branch (in units of time) joining the specified node to its parent. This is equivalent to >>> tree.time(tree.parent(u)) tree.time(u) The branch length for a node that has no parent (e.g., a root) is defined as zero. Note that this is not related to the property `.length` which | def branch_length(self, u):
ret = 0
parent = self.parent(u)
if parent != NULL:
ret = self.time(parent) - self.time(u)
return ret | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _self_time(self):\r\n return self.duration() - sum([child.duration() for child in self.children])",
"def height(node):\r\n \r\n height = 0\r\n temp = node\r\n while temp != None:\r\n temp = temp.parent\r\n height += 1\r\n return height",
"def get_tree_length(x):\n ... | [
"0.62321323",
"0.61979955",
"0.6108667",
"0.57897115",
"0.5644815",
"0.56318945",
"0.560745",
"0.55422705",
"0.5530762",
"0.55180126",
"0.55157197",
"0.55130166",
"0.55126524",
"0.54884946",
"0.5481138",
"0.5479378",
"0.54669785",
"0.54498905",
"0.5443167",
"0.54303825",
"0.5... | 0.7595638 | 0 |
Returns the sum of all the branch lengths in this tree (in units of time). This is equivalent to >>> sum(tree.branch_length(u) for u in tree.nodes()) Note that the branch lengths for root nodes are defined as zero. As this is defined by a traversal of the tree, technically we return the sum of all branch lengths that a... | def total_branch_length(self):
return self._ll_tree.get_total_branch_length() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_tree_size(self, node):\n\n # If the tree has not been created yet.\n if node == None:\n return 0\n n_nodes = 1\n for child in node.children:\n n_nodes += self.get_tree_size(node.children[child])\n return n_nodes",
"def size(self) -> int:\n #... | [
"0.67232084",
"0.6657682",
"0.655308",
"0.6537849",
"0.65087956",
"0.6490195",
"0.6471225",
"0.64446753",
"0.6431606",
"0.64251935",
"0.6411365",
"0.64068556",
"0.6379768",
"0.6378781",
"0.6376619",
"0.63538253",
"0.6294673",
"0.6291538",
"0.628126",
"0.62467563",
"0.62176985... | 0.7553698 | 0 |
Returns the time of the most recent common ancestor of the specified | def tmrca(self, *args):
mrca = self.mrca(*args)
if mrca == tskit.NULL:
raise ValueError(f"Nodes {args} do not share a common ancestor in the tree")
return self.get_time(mrca) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_recent_common_ancestor(self, nodes):\n if len(nodes) == 0:\n raise PhyloValueError(\"Error: could not determing the recent common ancestor, as no nodes were given.\")\n elif len(nodes) == 1:\n return nodes[0]\n ancestor = None\n for ancestor_nodes in zip(*(... | [
"0.6554634",
"0.65050995",
"0.61391026",
"0.59256375",
"0.5842648",
"0.58311296",
"0.5803403",
"0.5739744",
"0.5595866",
"0.55575806",
"0.5544612",
"0.55312806",
"0.5490737",
"0.54902107",
"0.5481298",
"0.5410377",
"0.5398516",
"0.5353187",
"0.5347455",
"0.53038716",
"0.52883... | 0.6653603 | 0 |
A numpy array (dtype=np.int32) encoding the parent of each node in this tree, such that ``tree.parent_array[u] == tree.parent(u)`` | def parent_array(self):
return self._parent_array | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_parent_space(self):\n\n parent_node = self.node+'_ZERO'\n parent_node = mc.ls(parent_node)\n\n if not parent_node:\n parent_node = utils.get_parent(self.const_node)\n\n parent_node = mc.ls(parent_node)\n\n if parent_node:\n return ['parent', par... | [
"0.64068717",
"0.6389879",
"0.6295633",
"0.62101763",
"0.61460817",
"0.6115075",
"0.6031045",
"0.5978492",
"0.596866",
"0.5960877",
"0.5954895",
"0.59531283",
"0.5944082",
"0.591997",
"0.591997",
"0.59132826",
"0.59015626",
"0.59015626",
"0.5899459",
"0.58732176",
"0.58552366... | 0.6957195 | 0 |
A numpy array (dtype=np.int32) encoding the left child of each node in this tree, such that ``tree.left_child_array[u] == tree.left_child(u)`` | def left_child_array(self):
return self._left_child_array | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def left_root(self):\n return self.left_child(self.virtual_root)",
"def left(self, node):\n self._validate_node(node)\n idx = node._index\n left_idx = 2*idx + 1\n if left_idx >= self._N:\n return None # Exceeds length of array\n return ... | [
"0.67617476",
"0.6732078",
"0.67109734",
"0.6637491",
"0.65278846",
"0.65083957",
"0.64609236",
"0.64485955",
"0.6423586",
"0.6423586",
"0.6412179",
"0.6411588",
"0.64056903",
"0.6401069",
"0.6392628",
"0.63455385",
"0.6335596",
"0.6332378",
"0.6331963",
"0.6280451",
"0.62632... | 0.80260164 | 0 |
A numpy array (dtype=np.int32) encoding the right child of each node in this tree, such that ``tree.right_child_array[u] == tree.right_child(u)`` | def right_child_array(self):
return self._right_child_array | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rightSideView(self, root):\n # If root is None, then return an empty array\n if not root:\n return []\n\n # Initialize a result array\n result = []\n\n # Initialize a array which holds all nodes at a given level\n level = [root]\n\n # Loop while level... | [
"0.6658737",
"0.6358942",
"0.6169108",
"0.6039245",
"0.6033303",
"0.6025593",
"0.6015385",
"0.6008446",
"0.594977",
"0.5939781",
"0.59339017",
"0.5924157",
"0.59008336",
"0.58797574",
"0.5807086",
"0.5787025",
"0.57789123",
"0.5769062",
"0.5753443",
"0.5744418",
"0.5706821",
... | 0.76158994 | 0 |
A numpy array (dtype=np.int32) encoding the left sib of each node in this tree, such that ``tree.left_sib_array[u] == tree.left_sib(u)`` | def left_sib_array(self):
return self._left_sib_array | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def lefts(self):\n lstack = [len(self.arr)]\n i = len(self.arr) - 1\n while i >= 0:\n if self.arr[i] > self.arr[lstack[-1] - 1]:\n while lstack and self.arr[i] > self.arr[lstack[-1] - 1]:\n x = lstack.pop()\n self.left[x - 1] = i ... | [
"0.65817153",
"0.62442845",
"0.6027532",
"0.59312594",
"0.5828023",
"0.5823536",
"0.5681712",
"0.5678256",
"0.563284",
"0.55682176",
"0.5558457",
"0.5552096",
"0.5552096",
"0.55176693",
"0.54819995",
"0.5470235",
"0.54533005",
"0.53899395",
"0.5374653",
"0.5356871",
"0.533722... | 0.7775731 | 0 |
A numpy array (dtype=np.int32) encoding the right sib of each node in this tree, such that ``tree.right_sib_array[u] == tree.right_sib(u)`` | def right_sib_array(self):
return self._right_sib_array | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def right_binarize(tree):\n\tif is_leaf(tree):\n\t\treturn tree\n\telif len(tree) > 2:\n\t\ttree = [tree[0], tree[1:]]\n\treturn [right_binarize(b) for b in tree]",
"def left_sib_array(self):\n return self._left_sib_array",
"def right_child_array(self):\n return self._right_child_array",
"def r... | [
"0.6135782",
"0.58304983",
"0.57966053",
"0.56505275",
"0.56286645",
"0.55224293",
"0.54671305",
"0.542581",
"0.5423493",
"0.5328281",
"0.5224316",
"0.52028126",
"0.51505506",
"0.5139011",
"0.5099461",
"0.5089879",
"0.5075082",
"0.5061901",
"0.5061901",
"0.50411457",
"0.50009... | 0.77877885 | 0 |
Returns the sibling(s) of the specified node ``u`` as a tuple of integer node IDs. If ``u`` has no siblings or is not a node in the current tree, returns an empty tuple. If ``u`` is the root of a singleroot tree, returns an empty tuple; if ``u`` is the root of a multiroot tree, returns the other roots (note all the roo... | def siblings(self, u):
if u == self.virtual_root:
return tuple()
parent = self.parent(u)
if self.is_root(u):
parent = self.virtual_root
if parent != tskit.NULL:
return tuple(v for v in self.children(parent) if u != v)
return tuple() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sibling(self, n):\n parent = self.parent(n)\n if parent is None: # n is root\n return None\n if n == self.left(parent): # n is left child\n return self.right(parent)\n else: # n is right child\n return self... | [
"0.5740031",
"0.57219934",
"0.5650593",
"0.5550569",
"0.54737085",
"0.53957033",
"0.5385634",
"0.5306878",
"0.52699095",
"0.52401435",
"0.5203835",
"0.5203835",
"0.5195068",
"0.5176321",
"0.5175656",
"0.5061357",
"0.50355077",
"0.50045",
"0.49930573",
"0.49924406",
"0.4990390... | 0.8250709 | 0 |
A numpy array (dtype=np.int32) encoding the number of children of each node in this tree, such that ``tree.num_children_array[u] == tree.num_children(u)`` for all | def num_children_array(self):
return self._num_children_array | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def n_children(self):\n ch = self.children\n return 0 if not ch else len(ch) + sum([c.n_children for c in ch])",
"def _children_count(self):\n cnt = 0\n if self.left:\n cnt += 1\n if self.right:\n cnt += 1\n return cnt",
"def children_count(self):... | [
"0.76257855",
"0.7521437",
"0.7251584",
"0.7239707",
"0.723105",
"0.72226125",
"0.7211807",
"0.7181553",
"0.71064436",
"0.70791054",
"0.6981291",
"0.68988043",
"0.68868345",
"0.68491983",
"0.68443114",
"0.68312865",
"0.67808044",
"0.6759831",
"0.6754965",
"0.67434806",
"0.673... | 0.82940614 | 0 |
Returns the id of the edge encoding the relationship between ``u`` | def edge(self, u):
return self._ll_tree.get_edge(u) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_edge_by_id(self, u: Hashable, v: Hashable):\n return (\n self._g.V()\n .has(ID, u)\n .outE()\n .as_(\"e\")\n .inV()\n .has(ID, v)\n .select(\"e\")\n .properties()\n .toList()\n )[0]",
"def get... | [
"0.7032687",
"0.6629317",
"0.65194345",
"0.62653863",
"0.6121014",
"0.6087408",
"0.59269035",
"0.5878909",
"0.5846011",
"0.5746643",
"0.571003",
"0.57015854",
"0.56637293",
"0.5629182",
"0.56277514",
"0.5545767",
"0.5511912",
"0.54222983",
"0.54194015",
"0.5406603",
"0.540382... | 0.7111198 | 0 |
The ID of the virtual root in this tree. This is equal to | def virtual_root(self):
return self._ll_tree.get_virtual_root() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tree_id(self):\n if self.is_root:\n return 0\n elif self._link is not None:\n return self._link.tree_id\n else:\n return self._tree_id",
"def rootid(self):\n candidates = [nid for nid, attrs\n in self.graph.nodes.items()\n ... | [
"0.78315955",
"0.7315934",
"0.7231198",
"0.70782566",
"0.6982469",
"0.6873987",
"0.68670744",
"0.6860683",
"0.6651226",
"0.66042686",
"0.6570657",
"0.645253",
"0.645253",
"0.6418725",
"0.63987726",
"0.63987726",
"0.63987726",
"0.63737303",
"0.63737303",
"0.63652235",
"0.63510... | 0.76485914 | 1 |
The total number of edges in this tree. This is equal to the number of tree sequence edges that intersect with this tree's genomic interval. Note that this may be greater than the number of branches that are reachable from the tree's roots, since we can have topology that is not associated with any samples. | def num_edges(self):
return self._ll_tree.get_num_edges() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def number_of_edges(self) -> int:\n return self.graph.number_of_edges()",
"def num_edges(self):\n return sum(1 for _ in self.iteredges())",
"def num_edges(self):\r\n return len(self.__generate_edges())",
"def num_edges(self):\n return self._top_exp.number_of_edges()",
"def edge_... | [
"0.83892447",
"0.82065594",
"0.8164331",
"0.8142472",
"0.7962753",
"0.79174477",
"0.7909009",
"0.7905368",
"0.7872033",
"0.78280866",
"0.782253",
"0.77930486",
"0.7676532",
"0.75563234",
"0.7542368",
"0.7510252",
"0.7501979",
"0.7486827",
"0.7431027",
"0.73827606",
"0.7374399... | 0.8547094 | 0 |
The leftmost root in this tree. If there are multiple roots in this tree, they are siblings of this node, and so we can | def left_root(self):
return self.left_child(self.virtual_root) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getLeftmost(self, root):\n current = root\n while current.left is not None:\n current = current.left\n return current",
"def root(self):\n if self.has_multiple_roots:\n raise ValueError(\"More than one root exists. Use tree.roots instead\")\n return se... | [
"0.8530952",
"0.8295624",
"0.8063771",
"0.77618504",
"0.77275914",
"0.7617638",
"0.76144713",
"0.7497168",
"0.7415707",
"0.7381646",
"0.7339204",
"0.7339204",
"0.7316175",
"0.73061645",
"0.72837955",
"0.72581136",
"0.7250919",
"0.7238245",
"0.7197334",
"0.7139504",
"0.7093866... | 0.84995955 | 1 |
Returns the children of the specified node ``u`` as a tuple of integer node IDs. If ``u`` is a leaf, return the empty tuple. The ordering of children is arbitrary and should not be depended on; see the | def children(self, u):
return self._ll_tree.get_children(u) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def siblings(self, u):\n if u == self.virtual_root:\n return tuple()\n parent = self.parent(u)\n if self.is_root(u):\n parent = self.virtual_root\n if parent != tskit.NULL:\n return tuple(v for v in self.children(parent) if u != v)\n return tuple(... | [
"0.70097744",
"0.6166763",
"0.569762",
"0.5613714",
"0.5411131",
"0.5312682",
"0.53055763",
"0.52821726",
"0.5210112",
"0.52022755",
"0.50422174",
"0.50117564",
"0.5005202",
"0.49577156",
"0.4931148",
"0.49260312",
"0.49067977",
"0.4898888",
"0.48970637",
"0.4877235",
"0.4828... | 0.7239634 | 0 |
Returns the time of the specified node. This is equivalently to ``tree.tree_sequence.node(u).time`` except for the special | def time(self, u):
return self._ll_tree.get_time(u) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def nodes_time(self):\n return self._nodes_time",
"def _time(self):\n return self.r.eval(self.LUA_TIME, 1, 1)",
"def get_time(self) -> float:\n raise NotImplementedError()",
"def time(self) -> int:\n return self.raw[\"time\"]",
"def getTime(self) -> float:\n return self.t... | [
"0.68615615",
"0.65732265",
"0.65536517",
"0.65356874",
"0.652617",
"0.6523616",
"0.64099526",
"0.6344309",
"0.6331385",
"0.6331385",
"0.6331385",
"0.6321756",
"0.6314839",
"0.6282078",
"0.62624884",
"0.6249831",
"0.6234953",
"0.61757624",
"0.6169039",
"0.6163151",
"0.6129707... | 0.7684374 | 0 |
Returns the number of nodes on the path from ``u`` to a root, not including ``u``. Thus, the depth of a root is zero. | def depth(self, u):
return self._ll_tree.depth(u) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def path_length(self, u, v):\n mrca = self.mrca(u, v)\n if mrca == -1:\n return math.inf\n return self.depth(u) + self.depth(v) - 2 * self.depth(mrca)",
"def num_children(self, u):\n return self._ll_tree.get_num_children(u)",
"def countNodes(self, root):\n\n\n if n... | [
"0.6907716",
"0.6741348",
"0.6526132",
"0.6396801",
"0.63941246",
"0.63751817",
"0.63441503",
"0.62831146",
"0.62447625",
"0.6199475",
"0.61980486",
"0.61909664",
"0.6149841",
"0.6093307",
"0.60787004",
"0.606168",
"0.6051738",
"0.6051738",
"0.6049776",
"0.6016154",
"0.598113... | 0.70626307 | 0 |
Returns the population associated with the specified node. Equivalent to ``tree.tree_sequence.node(u).population``. | def population(self, u):
return self._ll_tree.get_population(u) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def nodes_population(self):\n return self._nodes_population",
"def getPopulation(self):\n\n return self.population",
"def population(self):\n return self._population",
"def getPopulation(self):\n\n return self.p",
"def individuals_population(self):\n if self._individuals_... | [
"0.6784931",
"0.66868186",
"0.6671219",
"0.6613403",
"0.6545175",
"0.6408209",
"0.5859342",
"0.5636312",
"0.5636312",
"0.5532357",
"0.5437146",
"0.5424976",
"0.533153",
"0.5321826",
"0.51789737",
"0.51076955",
"0.5102596",
"0.50667673",
"0.5046358",
"0.5045376",
"0.49939802",... | 0.7531694 | 0 |
Returns True if the specified node u is a descendant of node v and False | def is_descendant(self, u, v):
return bool(self._ll_tree.is_descendant(u, v)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def eligible(self, u, v):\n return self.eligible_node(u) and self.eligible_node(v) and u != v",
"def is_descendant_of(self, node):\n return False",
"def contains_edge(self, u: str, v: str) -> bool:\n if v in self.adj_list[u]:\n return True\n else:\n return Fals... | [
"0.67513067",
"0.6651758",
"0.6277692",
"0.6143113",
"0.6118364",
"0.606495",
"0.6027384",
"0.5906157",
"0.5807102",
"0.57325053",
"0.5686264",
"0.5659878",
"0.5653369",
"0.5648461",
"0.5648461",
"0.56036127",
"0.55547583",
"0.5538231",
"0.55092",
"0.55059576",
"0.54525024",
... | 0.8073366 | 0 |
``True`` if this tree has a single root, ``False`` otherwise. Equivalent to tree.num_roots == 1. This is a O(1) operation. | def has_single_root(self):
root = self.left_root
if root != NULL and self.right_sib(root) == NULL:
return True
return False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_root(self, node: Node) -> bool:\n return node == self._root",
"def is_root(self):\n return (self.__type & NODE_ROOT) == NODE_ROOT",
"def is_root(self, node: object) -> bool:\n if node == self.root:\n return True\n else:\n return False",
"def is_root(se... | [
"0.7591037",
"0.75851834",
"0.75731367",
"0.7566736",
"0.7517388",
"0.7484943",
"0.74769217",
"0.74769217",
"0.7353206",
"0.73307997",
"0.73135406",
"0.73135406",
"0.73135406",
"0.72706574",
"0.72520506",
"0.7231739",
"0.7199155",
"0.719853",
"0.7187345",
"0.71370584",
"0.709... | 0.85853666 | 0 |
``True`` if this tree has more than one root, ``False`` otherwise. Equivalent to tree.num_roots > 1. This is a O(1) operation. | def has_multiple_roots(self):
root = self.left_root
if root != NULL and self.right_sib(root) != NULL:
return True
return False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def has_single_root(self):\n root = self.left_root\n if root != NULL and self.right_sib(root) == NULL:\n return True\n return False",
"def is_leaf(self):\n return len(self._children) == 0",
"def is_leaf(self):\n return len(self.children) == 0",
"def hasChildren(s... | [
"0.77078867",
"0.72200096",
"0.7202349",
"0.70940274",
"0.70692855",
"0.7057196",
"0.7055904",
"0.70332634",
"0.7010167",
"0.69933486",
"0.6961668",
"0.6945964",
"0.6934039",
"0.6909428",
"0.6868571",
"0.6861342",
"0.68255293",
"0.68226326",
"0.68204933",
"0.6804069",
"0.6791... | 0.7696039 | 1 |
The root of this tree. If the tree contains multiple roots, a ValueError is | def root(self):
if self.has_multiple_roots:
raise ValueError("More than one root exists. Use tree.roots instead")
return self.left_root | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rootid(self):\n candidates = [nid for nid, attrs\n in self.graph.nodes.items()\n if attrs['type'] == 'root']\n \n if len(candidates) > 1:\n errmsg = self.name + ' has more than one root'\n raise ValueError(errmsg)\n\n i... | [
"0.7650327",
"0.7567495",
"0.75478023",
"0.75264895",
"0.7517701",
"0.7505328",
"0.7505328",
"0.7392501",
"0.73842335",
"0.7363773",
"0.7332009",
"0.729036",
"0.729036",
"0.729036",
"0.72737736",
"0.72705334",
"0.726099",
"0.7182403",
"0.7167158",
"0.7167158",
"0.71592534",
... | 0.843541 | 0 |
Returns the total number of mutations across all sites on this tree. | def num_mutations(self):
return sum(len(site.mutations) for site in self.sites()) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getNNodesTot(self):\n nNodesTot = 0\n for iElt in Elements._all:\n nNodesTot += len(iElt.coord)\n return nNodesTot",
"def n(self):\n return len(self.data.sites)",
"def count_fragments(self):\n n = 0\n for chain in self.iter_chains():\n n += ch... | [
"0.67348415",
"0.662731",
"0.6496893",
"0.6496893",
"0.6428826",
"0.6404178",
"0.6404178",
"0.63672894",
"0.6320409",
"0.6299668",
"0.62946934",
"0.62711215",
"0.6259283",
"0.6250409",
"0.6248343",
"0.623999",
"0.62160534",
"0.62148464",
"0.61757725",
"0.61757725",
"0.6095577... | 0.8007304 | 0 |
Returns the number of sites on this tree. | def num_sites(self):
return self._ll_tree.get_num_sites() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def countSites(self):\n self.ni = len(self.sites)\n return self.ni",
"def number_of_sites(self) -> pulumi.Output[int]:\n return pulumi.get(self, \"number_of_sites\")",
"def number_of_sites(self) -> pulumi.Output[int]:\n return pulumi.get(self, \"number_of_sites\")",
"def n(self):\... | [
"0.8169985",
"0.8153402",
"0.8153402",
"0.8040949",
"0.74710983",
"0.72724086",
"0.7252431",
"0.72318196",
"0.72081715",
"0.7180082",
"0.71778214",
"0.7073089",
"0.7046339",
"0.7017032",
"0.70002794",
"0.69706094",
"0.692727",
"0.6909764",
"0.6909764",
"0.68881255",
"0.688632... | 0.8723763 | 0 |
Returns an iterator over the numerical IDs of all the sample nodes in this tree that are underneath the node with ID ``u``. If ``u`` is a sample, it is included in the returned iterator. If ``u`` is not a sample, it is possible for the returned iterator to be empty, for example if ``u`` is an | def samples(self, u=None):
roots = [u]
if u is None:
roots = self.roots
for root in roots:
yield from self._sample_generator(root) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_node_neighbors(\n self, u: Hashable, include_metadata: bool = False\n ) -> Generator:\n if include_metadata:\n return {\n e[\"target\"]: _node_to_metadata(e[\"properties\"])\n for e in (\n self._g.V()\n .has(ID,... | [
"0.5845915",
"0.5824988",
"0.57201153",
"0.56193584",
"0.5509862",
"0.53115594",
"0.524768",
"0.5234854",
"0.520216",
"0.5156979",
"0.5149246",
"0.50949883",
"0.5050001",
"0.49554256",
"0.49498004",
"0.49419135",
"0.4925439",
"0.4918073",
"0.49171185",
"0.49124178",
"0.489200... | 0.67430747 | 0 |
Returns the number of children of the specified node (i.e., ``len(tree.children(u))``) | def num_children(self, u):
return self._ll_tree.get_num_children(u) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def node_count_children(self, node):\n\n q = \"select count(node) from nodes where parent = ? and node != 0\"\n self.execute(q, (node,))\n r = self.fetchone()\n if r is None:\n return 0\n return r[0]",
"def _count_children(self, item):\n return len(self.tree.g... | [
"0.78681016",
"0.7801235",
"0.7707591",
"0.7542426",
"0.7536256",
"0.74991906",
"0.7485507",
"0.7485063",
"0.7358879",
"0.73557526",
"0.7266693",
"0.72642606",
"0.72609836",
"0.72561723",
"0.72537154",
"0.7252609",
"0.72342265",
"0.7222061",
"0.7106218",
"0.7097345",
"0.70955... | 0.845305 | 0 |
Returns the number of sample nodes in this tree underneath the specified node (including the node itself). If u is not specified return the total number of samples in the tree. This is a constant time operation. | def num_samples(self, u=None):
u = self.virtual_root if u is None else u
return self._ll_tree.get_num_samples(u) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def num_tracked_samples(self, u=None):\n u = self.virtual_root if u is None else u\n return self._ll_tree.get_num_tracked_samples(u)",
"def get_tree_size(self, node):\n\n # If the tree has not been created yet.\n if node == None:\n return 0\n n_nodes = 1\n for... | [
"0.71008927",
"0.6282148",
"0.60840005",
"0.5997149",
"0.5956238",
"0.5820769",
"0.57902974",
"0.57880586",
"0.57478213",
"0.57129973",
"0.5681754",
"0.5680819",
"0.5680611",
"0.56796664",
"0.5657526",
"0.56563616",
"0.56504655",
"0.56347567",
"0.5630829",
"0.5618458",
"0.560... | 0.7710853 | 0 |
Returns a numpy array of node ids. Starting at `u`, returns the reachable descendant nodes in order of increasing time (most recent first), falling back to increasing ID if times are equal. Also see | def timeasc(self, u=NULL):
nodes = self.preorder(u)
is_virtual_root = u == self.virtual_root
time = self.tree_sequence.nodes_time
if is_virtual_root:
# We could avoid creating this array if we wanted to, but
# it's not that often people will be using this with the... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def node_ids(self):\n # From: https://stackoverflow.com/questions/17415086/combine-consecutive-numbers-into-range-tuples\n groups = groupby(self.nodes.keys(), key=lambda item, c=count():item-next(c))\n temp = [list(g) for k, g in groups]\n return \"+\".join(\"{}-{}\".format(x[0], x[-1])... | [
"0.5835207",
"0.553332",
"0.5439752",
"0.5419785",
"0.5417405",
"0.5410128",
"0.53278786",
"0.53254324",
"0.5290489",
"0.52843225",
"0.5254525",
"0.52529585",
"0.52415806",
"0.523155",
"0.52021873",
"0.51625085",
"0.5155356",
"0.51531756",
"0.51510954",
"0.5137768",
"0.513090... | 0.5744613 | 1 |
Postorder traversal that visits leaves in minimum lexicographic order. Minlex stands for minimum lexicographic. We wish to visit a tree in such a way that the leaves visited, when their IDs are listed out, have minimum lexicographic order. This is a useful ordering for drawing multiple Trees of a TreeSequence, as it le... | def _minlex_postorder_traversal(self, root):
# We compute a dictionary mapping from internal node ID to min leaf ID
# under the node, using a first postorder traversal
min_leaf = {}
for u in self.nodes(root, order="postorder"):
if self.is_leaf(u):
min_leaf[u]... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def preorder(self):\n\n traversal = []\n self.preorder_helper(self.root, traversal)\n return traversal",
"def preorder(root):\n if not root:\n return\n print(root.data, end=' ')\n inorder(root.left)\n inorder(root.right)",
"def pre_order(self):\n stack = []\n node = se... | [
"0.6026168",
"0.60167783",
"0.6006228",
"0.59653455",
"0.595108",
"0.5914255",
"0.59076494",
"0.5866903",
"0.5866706",
"0.5861435",
"0.584913",
"0.5840987",
"0.576119",
"0.576119",
"0.5722962",
"0.5720179",
"0.57028884",
"0.5681403",
"0.5676662",
"0.5627623",
"0.5621951",
"... | 0.81445366 | 0 |
Call into the fast but limited C implementation of the newick conversion. | def _as_newick_fast(self, *, root, precision, legacy_ms_labels):
root_time = max(1, self.time(root))
max_label_size = math.ceil(math.log10(self.tree_sequence.num_nodes))
single_node_size = (
5 + max_label_size + math.ceil(math.log10(root_time)) + precision
)
buffer_si... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cast_to(ibuilder, data_amounts, src_buf, dst_buf):\n src_dtype = src_buf.dtype\n dst_dtype = dst_buf.dtype\n if src_dtype == \"float16\" and dst_dtype == \"int32\":\n vconv_instr = \"vconv_f162s32f\"\n vconv_compute_num = VEC_NUMS_HALF\n elif src_dtype == \"float32\" and dst_dtype == ... | [
"0.52168566",
"0.51054394",
"0.5024741",
"0.49913672",
"0.4964169",
"0.49437082",
"0.4942651",
"0.4938328",
"0.49358124",
"0.4892146",
"0.48736072",
"0.4861262",
"0.48581228",
"0.48443455",
"0.48441097",
"0.48344105",
"0.48191202",
"0.48119146",
"0.48069975",
"0.4801336",
"0.... | 0.5354915 | 0 |
Given observations for the samples in this tree described by the specified set of genotypes and alleles, return a parsimonious set of state transitions explaining these observations. The genotypes array is interpreted as indexes into the alleles list in the same manner as described in the | def map_mutations(self, genotypes, alleles, ancestral_state=None):
genotypes = util.safe_np_int_cast(genotypes, np.int8)
max_alleles = np.max(genotypes)
if ancestral_state is not None:
if isinstance(ancestral_state, str):
# Will raise a ValueError if not in the list
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def alleles(self) -> set[str]:\n return {self.ancestral_state} | {m.derived_state for m in self.mutations}",
"def build_markov_states(ngrams):\n\n state_spaces_grouped = list((str(ngram[:-1]),str(ngram[1:])) for ngram in ngrams)\n state_space = sorted(list(set(chain(*state_spaces_grouped))))\n\n ... | [
"0.54217005",
"0.53568363",
"0.5325274",
"0.5312335",
"0.5270767",
"0.50648093",
"0.506443",
"0.5060291",
"0.50200427",
"0.50167716",
"0.50167716",
"0.5014854",
"0.5010835",
"0.5004561",
"0.49944544",
"0.4994059",
"0.49931368",
"0.49931368",
"0.49729556",
"0.49683565",
"0.494... | 0.62167645 | 0 |
Returns the KendallColijn distance between the specified pair of trees. The ``lambda_`` parameter determines the relative weight of topology vs branch lengths in calculating the distance. If ``lambda_`` is 0 (the default) we only consider topology, and if it is 1 we only consider branch lengths. See `Kendall & Colijn (... | def kc_distance(self, other, lambda_=0.0):
return self._ll_tree.get_kc_distance(other._ll_tree, lambda_) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def lambda_dist(A1, A2, k=None, p=2, kind=\"laplacian\"):\n # ensure valid k\n n1, n2 = [A.shape[0] for A in [A1, A2]]\n N = min(n1, n2) # minimum size between the two graphs\n if k is None or k > N:\n k = N\n\n # form matrices\n L1, L2 = [laplacian_matrix(A) for A in [A1, A2]]\n # get... | [
"0.58686334",
"0.5573702",
"0.5117418",
"0.5098647",
"0.5075384",
"0.5072162",
"0.5029303",
"0.50228155",
"0.50145775",
"0.5003037",
"0.49983996",
"0.49670714",
"0.49365124",
"0.4936191",
"0.49070144",
"0.49058986",
"0.49017707",
"0.48971695",
"0.48962024",
"0.48683387",
"0.4... | 0.67535967 | 0 |
Returns the path length between two nodes (i.e., the number of edges between two nodes in this tree). If the two nodes have a most recent common ancestor, then this is defined as ``tree.depth(u) + tree.depth(v) 2 tree.depth(tree.mrca(u, v))``. If the nodes do not have an MRCA (i.e., they are in disconnected subtrees) t... | def path_length(self, u, v):
mrca = self.mrca(u, v)
if mrca == -1:
return math.inf
return self.depth(u) + self.depth(v) - 2 * self.depth(mrca) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def lineLength(node1, node2):\n return ((node2[1] - node1[1])**2 + (node2[0] - node1[0])**2)**(1/2)",
"def node_distance(self, node1, node2):\n if node1 == node2:\n return 0.0\n for i, (n1, n2) in enumerate(zip(self.paths[node1], self.paths[node2])):\n if n1 != n2:\n ... | [
"0.6622066",
"0.6376726",
"0.6292443",
"0.6278159",
"0.6270519",
"0.617931",
"0.6169958",
"0.61558205",
"0.61325884",
"0.61075735",
"0.6069739",
"0.60078466",
"0.60040367",
"0.59875345",
"0.58789146",
"0.58705115",
"0.58697885",
"0.58439183",
"0.5839832",
"0.5817393",
"0.5802... | 0.69861245 | 0 |
Returns the number of lineages present in this tree at time ``t``. This is defined as the number of branches in this tree (reachable from the samples) that intersect with ``t``. Thus, ``tree.num_lineages(t)`` is equal to 0 for any ``t`` greater than or equal to the time of the root in a singlyrooted tree. | def num_lineages(self, t):
return self._ll_tree.get_num_lineages(t) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def num_trees(self):\n return self._ll_tree_sequence.get_num_trees()",
"def leaf_count(t: Tree) -> int:\n if t.children == []:\n return 1\n else:\n return sum([leaf_count(child) for child in t.children])",
"def num_lines(self, snapshot: Bug, filepath: str) -> int:\n return len... | [
"0.58326685",
"0.5718193",
"0.5528552",
"0.54211223",
"0.5396871",
"0.5344715",
"0.5339605",
"0.5336183",
"0.53318506",
"0.53202033",
"0.52689475",
"0.52325475",
"0.5198714",
"0.5195046",
"0.5191032",
"0.51321983",
"0.5130129",
"0.51258403",
"0.5071875",
"0.50526863",
"0.5030... | 0.8463707 | 0 |
Parse the specified filelike object containing a whitespace delimited description of a population table and returns the corresponding | def parse_populations(
source, strict=True, encoding="utf8", base64_metadata=True, table=None
):
sep = None
if strict:
sep = "\t"
if table is None:
table = tables.PopulationTable()
# Read the header and find the indexes of the required fields.
header = source.readline().rstrip("\... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_records(self):\n for record in sp.parse(gzip.open(\n \"./human_uniprot_04_07_20.gz\", 'rt')):\n # print(record.taxonomy_id)\n # if record.organism != \"Homo sapiens\":\n # continue\n # print(record.features[0])\n # for comme... | [
"0.5623653",
"0.5606874",
"0.55521023",
"0.54336685",
"0.5417759",
"0.53463066",
"0.53443885",
"0.53144956",
"0.53142774",
"0.5312948",
"0.52549934",
"0.5252852",
"0.5217366",
"0.52172476",
"0.5212294",
"0.5206639",
"0.5206483",
"0.5191802",
"0.5171815",
"0.516349",
"0.515183... | 0.63037497 | 0 |
Parse the specified filelike object containing a whitespace delimited description of a migration table and returns the corresponding | def parse_migrations(
source, strict=True, encoding="utf8", base64_metadata=True, table=None
):
sep = None
if strict:
sep = "\t"
if table is None:
table = tables.MigrationTable()
header = source.readline().rstrip("\n").split(sep)
left_index = header.index("left")
right_index ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def convertTableName(fileName: str):\n if m := pattern.match(fileName):\n return m.group(\"tableName\")",
"def parse_migration_tables(self, tabels_schema: MigrationTablesSchema):\n try:\n self.source_table = tabels_schema.migrationTable.SourceTable.dict()\n self.destination... | [
"0.5700692",
"0.55202156",
"0.54392356",
"0.54001176",
"0.5343833",
"0.5315063",
"0.52907103",
"0.5255221",
"0.5230433",
"0.5211819",
"0.513428",
"0.51280427",
"0.5093966",
"0.50610334",
"0.50564736",
"0.50525755",
"0.50513554",
"0.50412977",
"0.50402623",
"0.49992043",
"0.49... | 0.6354695 | 0 |
Returns a dictionary mapping names to tables in the | def tables_dict(self):
return self.tables.table_name_map | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getTables(self):\n\treturn self.dbNames",
"def tables(self):\n cursor = self.connection.cursor()\n\n # not returning an iterator: just fetch everything.\n # I'm guessing this will be fine for any realistic database\n # size, and avoids issues of having multiple open cursors\n ... | [
"0.75579584",
"0.75529516",
"0.7496862",
"0.72894216",
"0.7044438",
"0.6950208",
"0.6903404",
"0.6877502",
"0.6809702",
"0.6778553",
"0.67474467",
"0.6715881",
"0.6714412",
"0.6704174",
"0.6666285",
"0.6663855",
"0.6659868",
"0.6648098",
"0.66260135",
"0.6587487",
"0.6578043"... | 0.8454422 | 0 |
Writes a text representation of the tables underlying the tree sequence to the specified connections. If Base64 encoding is not used, then metadata will be saved directly, possibly resulting in errors reading the tables back in if metadata includes whitespace. | def dump_text(
self,
nodes=None,
edges=None,
sites=None,
mutations=None,
individuals=None,
populations=None,
migrations=None,
provenances=None,
precision=6,
encoding="utf8",
base64_metadata=True,
):
text_formats.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _write_tables(self, size, card_writer):\n msg = []\n if self.tables:\n msg.append('$TABLES\\n')\n for (unused_id, table) in sorted(self.tables.iteritems()):\n msg.append(table.write_bdf(size, card_writer))\n\n if self.randomTables:\n msg.appe... | [
"0.54099345",
"0.52605677",
"0.5219329",
"0.5195038",
"0.50120956",
"0.49410546",
"0.49194938",
"0.49185073",
"0.4827271",
"0.4811166",
"0.47561288",
"0.4733279",
"0.47296384",
"0.47156334",
"0.47147253",
"0.47124082",
"0.46982387",
"0.4687151",
"0.46499118",
"0.46343625",
"0... | 0.5632372 | 0 |
Return an html summary of a tree sequence. Called by jupyter notebooks to render a TreeSequence. | def _repr_html_(self):
return util.tree_sequence_html(self) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __str__(self):\n ts_rows = [\n [\"Trees\", str(self.num_trees)],\n [\n \"Sequence Length\",\n str(\n int(self.sequence_length)\n if self.discrete_genome\n else self.sequence_length\n ... | [
"0.63479036",
"0.6299575",
"0.6234534",
"0.6145641",
"0.61443883",
"0.6126194",
"0.60292596",
"0.59683675",
"0.5962866",
"0.59068114",
"0.5906303",
"0.58818275",
"0.5820515",
"0.5766688",
"0.57612646",
"0.57337385",
"0.57069105",
"0.56929445",
"0.56822026",
"0.56800926",
"0.5... | 0.675806 | 0 |
Returns the number of sample nodes in this tree sequence. This is also the number of sample nodes in each tree. | def num_samples(self):
return self._ll_tree_sequence.get_num_samples() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def num_actual_nodes(tree):\n return (tree.n_node_samples > 0).sum()",
"def count(self):\n return self.__tree.node_count",
"def count_nodes(self):\n if self.children is None:\n return 0\n\n total_count = 0\n for child in self.children:\n if child is None... | [
"0.75340533",
"0.72002333",
"0.7187151",
"0.71474844",
"0.706328",
"0.7060709",
"0.7043023",
"0.7026021",
"0.702282",
"0.69940025",
"0.6987939",
"0.69874567",
"0.69519013",
"0.69288397",
"0.6921411",
"0.6905505",
"0.6892658",
"0.6860774",
"0.68527967",
"0.67772985",
"0.676849... | 0.8037324 | 0 |
The set of metadata schemas for the tables in this tree sequence. | def table_metadata_schemas(self) -> TableMetadataSchemas:
return self._table_metadata_schemas | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def schemas(self):\n return self.get_schemas()",
"def schemas(self):\n return model.Schemas(self)",
"def schemas(self) -> Dict[int, Schema]:\n return {schema.schema_id: schema for schema in self.metadata.schemas}",
"def get_schemas(self, conn):\n return conn.get_schemas()['table_s... | [
"0.7736832",
"0.7472868",
"0.74683195",
"0.70355356",
"0.7034384",
"0.70122963",
"0.6876386",
"0.6850239",
"0.6711756",
"0.65841955",
"0.64967495",
"0.6451351",
"0.6445532",
"0.64075005",
"0.6406947",
"0.63583755",
"0.6340326",
"0.632295",
"0.6320353",
"0.63107216",
"0.628728... | 0.7860056 | 0 |
Returns the min time in this tree sequence. This is the minimum of the node times and mutation times. Note that mutation times with the value ``tskit.UNKNOWN_TIME`` are ignored. | def min_time(self):
return self._ll_tree_sequence.get_min_time() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_min_tim(self):\n return self.get_shortest_mode().tim",
"def min_time(self) -> str:\n return self._min_time",
"def min(self):\n\n return time_stat(self, stat=\"min\")",
"def min_time(self):\n #{{{ function to return time of first sample\n\n return self.mintime",
"def initi... | [
"0.76301086",
"0.7540868",
"0.7337586",
"0.7212607",
"0.7120911",
"0.7066559",
"0.6846319",
"0.67451185",
"0.6688156",
"0.6661619",
"0.6616743",
"0.6535071",
"0.65190476",
"0.64759356",
"0.6434894",
"0.6425683",
"0.6409702",
"0.6400449",
"0.6400449",
"0.63828295",
"0.63797426... | 0.8721078 | 0 |
Returns the max time in this tree sequence. This is the maximum of the node times and mutation times. Note that mutation times with the value ``tskit.UNKNOWN_TIME`` are ignored. | def max_time(self):
return self._ll_tree_sequence.get_max_time() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def max_time(self) -> float:\r\n if(len(self.operations_by_name) == 0):\r\n return -1\r\n return max(map(lambda x: x[\"time_step\"], self.operations_by_name.values()))",
"def max_time(self):\n return self._max_time",
"def _get_max_t(self):\n \"\"\"\n if hasattr(sel... | [
"0.7535206",
"0.74210066",
"0.7383867",
"0.7319022",
"0.7315086",
"0.7299319",
"0.70352024",
"0.70182174",
"0.6946768",
"0.6593718",
"0.651949",
"0.65012175",
"0.64540786",
"0.64530516",
"0.6345061",
"0.6335531",
"0.6329964",
"0.63199276",
"0.6315849",
"0.62969947",
"0.627882... | 0.850162 | 0 |
The decoded metadata for this TreeSequence. | def metadata(self) -> Any:
return self.metadata_schema.decode_row(self._ll_tree_sequence.get_metadata()) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def metadata(self):\n return parse_metadata(self.metadata_path())",
"def metadata(self) -> t.Mapping[str, str]:\n return self._metadata",
"def metadata(self) -> Mapping[str, str]:\r\n return self._metadata",
"def metadata(self) -> Mapping[str, str]:\r\n return self._metadata",
"... | [
"0.6533288",
"0.63177395",
"0.63032943",
"0.63032943",
"0.6210358",
"0.6189749",
"0.61350304",
"0.61177075",
"0.61177075",
"0.61177075",
"0.61177075",
"0.61177075",
"0.6101394",
"0.6088947",
"0.6063599",
"0.6053583",
"0.6039628",
"0.6028858",
"0.5993135",
"0.59703493",
"0.595... | 0.7643683 | 0 |
String describing the units of the time dimension for this TreeSequence. | def time_units(self) -> str:
return self._ll_tree_sequence.get_time_units() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def unit_of_measurement(self) -> str:\n return MS",
"def unit_of_measurement(self) -> str:\n return self._unit_of_measurement",
"def unit_of_measurement(self) -> str:\n return self._unit",
"def get_time_unit(self, variables):\n if len(self.TIME_VARIABLE):\n # times = se... | [
"0.72310936",
"0.70552325",
"0.7010048",
"0.6959636",
"0.67902136",
"0.67902136",
"0.6776643",
"0.67292684",
"0.6727727",
"0.6701592",
"0.655505",
"0.6542371",
"0.6505851",
"0.6451159",
"0.64416",
"0.6433338",
"0.6433338",
"0.6426456",
"0.64193255",
"0.64193255",
"0.64193255"... | 0.81903493 | 0 |
Returns the time of the oldest root in any of the trees in this tree sequence. This is usually equal to ``np.max(ts.tables.nodes.time)`` but may not be since there can be nonsample nodes that are not present in any tree. Note that isolated samples are also defined as roots (so there can be a max_root_time even in a tre... | def max_root_time(self):
if self.num_samples == 0:
raise ValueError(
"max_root_time is not defined in a tree sequence with 0 samples"
)
ret = max(self.nodes_time[u] for u in self.samples())
if self.num_edges > 0:
# Edges are guaranteed to be li... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def min_time(self):\n return self._ll_tree_sequence.get_min_time()",
"def max_time(self):\n return self._ll_tree_sequence.get_max_time()",
"def timeasc(self, u=NULL):\n nodes = self.preorder(u)\n is_virtual_root = u == self.virtual_root\n time = self.tree_sequence.nodes_time\... | [
"0.68954426",
"0.6346282",
"0.58953196",
"0.58503944",
"0.5846507",
"0.5717475",
"0.5638166",
"0.5637577",
"0.5560268",
"0.5505343",
"0.5453994",
"0.5430241",
"0.54018915",
"0.53794503",
"0.5374859",
"0.53706455",
"0.5366049",
"0.5344357",
"0.53320587",
"0.53243273",
"0.52715... | 0.83293295 | 0 |
Returns the breakpoints that separate trees along the chromosome, including the two extreme points 0 and L. This is equivalent to >>> iter([0] + [t.interval.right for t in self.trees()]) By default we return an iterator over the breakpoints as Python float objects; if ``as_array`` is True we return them as a numpy arra... | def breakpoints(self, as_array=False):
breakpoints = self.ll_tree_sequence.get_breakpoints()
if not as_array:
# Convert to Python floats for backward compatibility.
breakpoints = map(float, breakpoints)
return breakpoints | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def binary_trees(self):\n for ip in self.lower_contained_intervals():\n yield ip.upper_binary_tree()",
"def find_breaks(self, time=None):\n if time is None:\n time = self.time\n diff = np.diff(time)\n ind = np.where((diff >= 2.5*np.std(diff)+np.nanmean(diff)))[0... | [
"0.5284244",
"0.48869777",
"0.48465636",
"0.48159292",
"0.472253",
"0.47032624",
"0.47031304",
"0.4685331",
"0.46752793",
"0.46584305",
"0.4646784",
"0.4646784",
"0.4644145",
"0.46395525",
"0.4632271",
"0.46194962",
"0.46112263",
"0.4602534",
"0.45954868",
"0.4594559",
"0.459... | 0.73138636 | 0 |
Returns the tree covering the specified genomic location. The returned tree will have ``tree.interval.left`` <= ``position`` < ``tree.interval.right``. | def at(self, position, **kwargs):
tree = Tree(self, **kwargs)
tree.seek(position)
return tree | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_rand_tree(position):\n max_width = random.randint(50, 100)\n min_width = random.randint(5, 10)\n itter_width = random.randint(5, 20)\n itter_height = random.randint(5, 20)\n random_tree = Tree(max_width, min_width, itter_width,\n itter_height)\n random_tree.loc_trans... | [
"0.6250308",
"0.5743139",
"0.5281273",
"0.52278715",
"0.5220417",
"0.509073",
"0.50863886",
"0.5030011",
"0.5015903",
"0.49898323",
"0.49448988",
"0.49328783",
"0.49303725",
"0.492744",
"0.4915386",
"0.49112505",
"0.49106944",
"0.48689145",
"0.4857485",
"0.48550114",
"0.47906... | 0.57501644 | 1 |
Returns an iterator over the pairs of trees for each distinct interval in the specified pair of tree sequences. | def coiterate(self, other, **kwargs):
if self.sequence_length != other.sequence_length:
raise ValueError("Tree sequences must be of equal sequence length.")
L = self.sequence_length
trees1 = self.trees(**kwargs)
trees2 = other.trees(**kwargs)
tree1 = next(trees1)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def expand_ranges(ranges):\n for low, high in low_high_pairs:\n for j in range(low, high+1):\n yield j",
"def _iter_pairs(graph):\n for u, v in set(graph.edges_iter()):\n yield u, v",
"def binary_trees(self):\n for ip in self.lower_contained_intervals():\n yield... | [
"0.61073774",
"0.5865318",
"0.5740975",
"0.57150364",
"0.57077706",
"0.56880534",
"0.5617956",
"0.55927145",
"0.54997987",
"0.5490317",
"0.5480926",
"0.54562974",
"0.5439498",
"0.5425205",
"0.5424179",
"0.54166687",
"0.541448",
"0.54016334",
"0.53926456",
"0.5391914",
"0.5375... | 0.6634346 | 0 |
Returns the length``num_individuals`` array containing, for each individual, the ``population`` attribute of their nodes, or ``tskit.NULL`` for individuals with no nodes. Errors if any individual has nodes with inconsistent nonNULL populations. | def individuals_population(self):
if self._individuals_population is None:
self._individuals_population = (
self._ll_tree_sequence.get_individuals_population()
)
return self._individuals_population | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def testNumberIndividuals(self):\n self.assertEqual(356, self.tree.get_number_individuals())\n self.assertEqual(53, self.tree.get_number_individuals(fragment=\"fragment1\"))\n self.assertEqual(53, self.tree.get_number_individuals(fragment=\"fragment1\", community_reference=1))\n self.as... | [
"0.6068806",
"0.6002879",
"0.5944986",
"0.58931047",
"0.58031034",
"0.57910883",
"0.5730337",
"0.57071805",
"0.55593824",
"0.5397286",
"0.5234656",
"0.51702505",
"0.5145613",
"0.5116316",
"0.50954235",
"0.50745404",
"0.5026472",
"0.49959508",
"0.48949358",
"0.47803336",
"0.47... | 0.6344032 | 0 |
Returns the length``num_individuals`` array containing, for each individual, the ``time`` attribute of their nodes or ``np.nan`` for individuals with no nodes. Errors if any individual has nodes with inconsistent times. | def individuals_time(self):
if self._individuals_time is None:
self._individuals_time = self._ll_tree_sequence.get_individuals_time()
return self._individuals_time | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_both_times(individuals):\n ambulance_patients_times = []\n other_patients_times = []\n patients_still_in_system = []\n\n for ind in individuals:\n if ind.data_records[0].node == 1 and len(ind.data_records) == 2:\n ambulance_patients_times.append(\n ind.data_reco... | [
"0.5987622",
"0.5948628",
"0.5613949",
"0.51615",
"0.51356566",
"0.495392",
"0.48835018",
"0.48367068",
"0.48311937",
"0.4776059",
"0.47709858",
"0.47437122",
"0.47318628",
"0.47132596",
"0.47126588",
"0.46759188",
"0.4612731",
"0.45933276",
"0.45790666",
"0.45784557",
"0.457... | 0.6505184 | 0 |
Convenience method returning the ``num_individuals x n`` array whose row kth row contains the ``location`` property of the kth individual. The method only works if all individuals' locations have the same length (which is ``n``), and errors otherwise. | def individuals_location(self):
if self._individuals_location is None:
individuals = self.tables.individuals
n = 0
lens = np.unique(np.diff(individuals.location_offset))
if len(lens) > 1:
raise ValueError("Individual locations are not all the same ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def locations_n(self):\n return self.locations[1]",
"def get_location_count(self):\n return len(self.matrix)",
"def nD(self):\n return self.locations.shape[0]",
"def location_length(self, location):\n return self.num_cells",
"def nD(self):\n return self.locations[0].shape... | [
"0.62515455",
"0.5696635",
"0.5599937",
"0.53917503",
"0.5334195",
"0.53217626",
"0.52864563",
"0.51888007",
"0.50179815",
"0.499822",
"0.499822",
"0.499822",
"0.49844116",
"0.49440056",
"0.49434376",
"0.49286446",
"0.49114847",
"0.4908877",
"0.48569283",
"0.4848078",
"0.4821... | 0.57730913 | 1 |
Efficient access to the ``edge_insertion_order`` column in the | def indexes_edge_insertion_order(self):
return self._indexes_edge_insertion_order | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def indexes_edge_removal_order(self):\n return self._indexes_edge_removal_order",
"def getOrder(self):\n return len(self.vertices)",
"def gather_referring_orders (gdbval):\n# TODO: Somehow also note speculative references and attributes in\n# general\n vec = gdbval[\"referring\"]\n return [... | [
"0.6358983",
"0.5900881",
"0.57451737",
"0.5697008",
"0.5653405",
"0.56280744",
"0.5623818",
"0.5623705",
"0.56159633",
"0.5571078",
"0.5571078",
"0.5571078",
"0.55381864",
"0.5503881",
"0.54637563",
"0.5428391",
"0.5388596",
"0.53514075",
"0.53380424",
"0.5337527",
"0.532368... | 0.76483953 | 0 |
Efficient access to the ``edge_removal_order`` column in the | def indexes_edge_removal_order(self):
return self._indexes_edge_removal_order | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def indexes_edge_insertion_order(self):\n return self._indexes_edge_insertion_order",
"def remove_edge(self, edge: Edge) -> Edge:",
"def targeted_order(ugraph):\r\n # copy the graph\r\n new_graph = copy_graph(ugraph)\r\n \r\n order = [] \r\n while len(new_graph) > 0:\r\n max_deg... | [
"0.6143712",
"0.5672081",
"0.5546742",
"0.55355215",
"0.55350184",
"0.55093086",
"0.55093086",
"0.5497397",
"0.54927194",
"0.54504806",
"0.54504806",
"0.544773",
"0.5420525",
"0.5417564",
"0.5400757",
"0.5354836",
"0.5296656",
"0.5250233",
"0.523544",
"0.522699",
"0.5222479",... | 0.7645291 | 0 |
Returns an array of the sample node IDs in this tree sequence. If `population` is specified, only return sample IDs from that population. It is also possible to restrict samples by time using the parameter `time`. If `time` is a numeric value, only return sample IDs whose node time is approximately equal to the specifi... | def samples(self, population=None, *, population_id=None, time=None):
if population is not None and population_id is not None:
raise ValueError(
"population_id and population are aliases. Cannot specify both"
)
if population_id is not None:
population ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def split_edges(self, time, *, flags=None, population=None, metadata=None):\n population = tskit.NULL if population is None else population\n flags = 0 if flags is None else flags\n schema = self.table_metadata_schemas.node\n if metadata is None:\n metadata = schema.empty_val... | [
"0.52388084",
"0.51924205",
"0.50169605",
"0.48772246",
"0.48648888",
"0.47995767",
"0.47955135",
"0.47742298",
"0.47703192",
"0.47635522",
"0.45920202",
"0.4576549",
"0.4572421",
"0.45669293",
"0.4562259",
"0.45152733",
"0.44779062",
"0.44591126",
"0.44388416",
"0.44195712",
... | 0.8056126 | 0 |
Returns a simplified tree sequence that retains only the history of the nodes given in the list ``samples``. If ``map_nodes`` is true, also return a numpy array whose ``u``th element is the ID of the node in the simplified tree sequence that corresponds to node ``u`` in the | def simplify(
self,
samples=None,
*,
map_nodes=False,
reduce_to_site_topology=False,
filter_populations=None,
filter_individuals=None,
filter_sites=None,
filter_nodes=None,
update_sample_flags=None,
keep_unary=False,
keep_un... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def predict(tree, samples):\n ret = np.empty(samples.shape[0], dtype=float)\n ret.fill(-1)\n indices = np.arange(samples.shape[0])\n\n def tranverse(node, indices):\n nonlocal samples\n nonlocal ret\n\n if node['leaf']:\n ret[indices] = node['class']\n\n else:\n ... | [
"0.54556483",
"0.48020166",
"0.47507343",
"0.46915585",
"0.46181074",
"0.45964795",
"0.45849374",
"0.45764282",
"0.45518264",
"0.45434403",
"0.45379174",
"0.44951925",
"0.44686627",
"0.44523057",
"0.44497302",
"0.44371644",
"0.44355956",
"0.44289804",
"0.440221",
"0.43840438",
... | 0.6680991 | 0 |
Returns a copy of this tree sequence with the specified sites (and their associated mutations) entirely removed. The site IDs do not need to be in any particular order, and specifying the same ID multiple times does not have any effect (i.e., calling ``tree_sequence.delete_sites([0, 1, 1])`` has the same effect as call... | def delete_sites(self, site_ids, record_provenance=True):
tables = self.dump_tables()
tables.delete_sites(site_ids, record_provenance)
return tables.tree_sequence() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def deduplicate_motif_sites(sites, length):\n for sites_by_region in sites:\n idx = 0\n if len(sites_by_region) > 1:\n while idx + 1 < len(sites_by_region):\n site_curr = sites_by_region[idx]\n site_next = sites_by_region[idx + 1]\n if site_n... | [
"0.58835953",
"0.5513648",
"0.550245",
"0.5346258",
"0.5169887",
"0.5104389",
"0.5094161",
"0.5076627",
"0.50510496",
"0.49479473",
"0.48994976",
"0.47457847",
"0.45468628",
"0.45371032",
"0.45204517",
"0.44975597",
"0.44626418",
"0.44420925",
"0.44187573",
"0.44008335",
"0.4... | 0.6735055 | 0 |
Returns a copy of this tree sequence for which information in the specified list of genomic intervals has been deleted. Edges spanning these intervals are truncated or deleted, and sites and mutations falling within them are discarded. Note that it is the information in the intervals that is deleted, not the intervals ... | def delete_intervals(self, intervals, simplify=True, record_provenance=True):
tables = self.dump_tables()
tables.delete_intervals(intervals, simplify, record_provenance)
return tables.tree_sequence() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def keep_intervals(self, intervals, simplify=True, record_provenance=True):\n tables = self.dump_tables()\n tables.keep_intervals(intervals, simplify, record_provenance)\n return tables.tree_sequence()",
"def genomic_deletion():\n params = {\n \"id\": \"normalize.variation:NC_00000... | [
"0.5810915",
"0.561506",
"0.53758883",
"0.53427774",
"0.53042847",
"0.5264808",
"0.51077783",
"0.50922674",
"0.50617796",
"0.5046205",
"0.50359815",
"0.49925306",
"0.49372274",
"0.4936038",
"0.4873826",
"0.4847486",
"0.48172253",
"0.48066944",
"0.47908092",
"0.47852188",
"0.4... | 0.67336595 | 0 |
Returns a copy of this tree sequence which includes only information in the specified list of genomic intervals. Edges are truncated to lie within these intervals, and sites and mutations falling outside these intervals are discarded. Note that it is the information outside the intervals that is deleted, not the interv... | def keep_intervals(self, intervals, simplify=True, record_provenance=True):
tables = self.dump_tables()
tables.keep_intervals(intervals, simplify, record_provenance)
return tables.tree_sequence() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_intervals(self, intervals, simplify=True, record_provenance=True):\n tables = self.dump_tables()\n tables.delete_intervals(intervals, simplify, record_provenance)\n return tables.tree_sequence()",
"def get_interval_seqs(interval_alignment: AlignIO.MultipleSeqAlignment):\n gaple... | [
"0.6326435",
"0.5249974",
"0.51594526",
"0.5091549",
"0.5084901",
"0.50151855",
"0.49217707",
"0.47864985",
"0.4773054",
"0.47546118",
"0.4744292",
"0.46996033",
"0.46527687",
"0.4646743",
"0.46268925",
"0.45575058",
"0.4550034",
"0.452481",
"0.45219132",
"0.4521416",
"0.4502... | 0.6803506 | 0 |
Returns a copy of this tree sequence in which we replace any edge ``(left, right, parent, child)`` in which ``node_time[child] < time < node_time[parent]`` with two edges ``(left, right, parent, u)`` and ``(left, right, u, child)``, where ``u`` is a newly added node for each intersecting edge. If ``metadata``, ``flags`... | def split_edges(self, time, *, flags=None, population=None, metadata=None):
population = tskit.NULL if population is None else population
flags = 0 if flags is None else flags
schema = self.table_metadata_schemas.node
if metadata is None:
metadata = schema.empty_value
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _alter_node(node):\n if isinstance(node, (de.TFRecordDataset, de.TextFileDataset)) and node.shuffle_level == de.Shuffle.GLOBAL:\n # Remove the connection between the parent's node to the current node because we are inserting a node.\n if node.output:\n node.output.pop()\n # P... | [
"0.51950336",
"0.5176023",
"0.50183296",
"0.5000768",
"0.49941224",
"0.49919954",
"0.49784195",
"0.49057677",
"0.4821747",
"0.48118603",
"0.47976103",
"0.4786827",
"0.47758043",
"0.4763584",
"0.47414204",
"0.46887398",
"0.46823126",
"0.46703735",
"0.46471465",
"0.46146598",
"... | 0.58031756 | 0 |
Delete all edge topology and mutational information at least as old as the specified time from this tree sequence. Removes all edges in which the time of the child is >= the specified time ``t``, and breaks edges that intersect with ``t``. For each edge intersecting with ``t`` we create a new node with time equal to ``... | def decapitate(self, time, *, flags=None, population=None, metadata=None):
split_ts = self.split_edges(
time, flags=flags, population=population, metadata=metadata
)
tables = split_ts.dump_tables()
del split_ts
tables.delete_older(time)
return tables.tree_sequ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def split_edges(self, time, *, flags=None, population=None, metadata=None):\n population = tskit.NULL if population is None else population\n flags = 0 if flags is None else flags\n schema = self.table_metadata_schemas.node\n if metadata is None:\n metadata = schema.empty_val... | [
"0.6175342",
"0.50200623",
"0.49097854",
"0.4899194",
"0.4897589",
"0.48830342",
"0.48272425",
"0.48249716",
"0.48210132",
"0.4797195",
"0.47439253",
"0.47413278",
"0.47352284",
"0.4734214",
"0.47046345",
"0.47020596",
"0.4697057",
"0.46798575",
"0.4666025",
"0.46570754",
"0.... | 0.63229364 | 0 |
Returns an expanded tree sequence which contains the nodewise union of ``self`` and ``other``, obtained by adding the nonshared portions of ``other`` onto ``self``. The "shared" portions are specified using a map that specifies which nodes in ``other`` are equivalent to those in | def union(
self,
other,
node_mapping,
check_shared_equality=True,
add_populations=True,
record_provenance=True,
):
tables = self.dump_tables()
other_tables = other.dump_tables()
tables.union(
other_tables,
node_mapping,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def join_union(self, other):\n\n assert type(self) is type(other), 'Expected NestedRE instance'\n\n A = self.make_flat()\n B = other.make_flat()\n\n if A == B and A !='ϵ':\n return self.merge_union(A, [self.closure, other.closure])\n elif A == 'ϵ' and B == 'ϵ':\n ... | [
"0.6619934",
"0.66133",
"0.6611823",
"0.658951",
"0.6457247",
"0.6290051",
"0.61989576",
"0.6167337",
"0.6109577",
"0.61043054",
"0.6033469",
"0.6019114",
"0.60060364",
"0.5984011",
"0.5972222",
"0.5958842",
"0.5918615",
"0.5903366",
"0.58956176",
"0.5891529",
"0.5873708",
... | 0.70766383 | 0 |
Return an SVG representation of a tree sequence. See the | def draw_svg(
self,
path=None,
*,
size=None,
x_scale=None,
time_scale=None,
tree_height_scale=None,
node_labels=None,
mutation_labels=None,
root_svg_attributes=None,
style=None,
order=None,
force_root_branch=None,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tree2gv(tree: TreeNode) -> graphviz.Graph:\n result = graphviz.Graph(\"ni\")\n # result.attr(size='12,0')\n tree2gv_helper(tree, result, \"\")\n return result",
"def _repr_svg_(self):\n pass",
"def tree(self):\n return self.to_geom()",
"def to_svg(self, outfile, scaling, precisi... | [
"0.69250715",
"0.6747924",
"0.6678924",
"0.6532394",
"0.65017956",
"0.65017956",
"0.62806135",
"0.62691665",
"0.6204719",
"0.6181917",
"0.611977",
"0.60983145",
"0.60898256",
"0.6087089",
"0.6041106",
"0.6032947",
"0.60165817",
"0.60165817",
"0.6015181",
"0.59928304",
"0.5985... | 0.6900163 | 1 |
r""" Computes mean genetic divergence between (and within) pairs of sets of nodes from ``sample_sets``. This is the "average number of differences", usually referred to as "dxy"; a common citation for this definition is Nei and Li (1979), who called it | def divergence(
self, sample_sets, indexes=None, windows=None, mode="site", span_normalise=True
):
return self.__k_way_sample_set_stat(
self._ll_tree_sequence.divergence,
2,
sample_sets,
indexes=indexes,
windows=windows,
mode=mo... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def mean_descendants(self, sample_sets):\n return self._ll_tree_sequence.mean_descendants(sample_sets)",
"def genetic_relatedness(\n self,\n sample_sets,\n indexes=None,\n windows=None,\n mode=\"site\",\n span_normalise=True,\n polarised=False,\n pro... | [
"0.65938085",
"0.6017522",
"0.5720115",
"0.56957686",
"0.5584161",
"0.55598336",
"0.5409914",
"0.5408993",
"0.5395803",
"0.5383368",
"0.53729755",
"0.53599113",
"0.5354259",
"0.53529006",
"0.5323027",
"0.53085446",
"0.52953327",
"0.52906203",
"0.528776",
"0.5276869",
"0.52511... | 0.66601527 | 0 |
Returns a list of (at most) num_chunks windows, which represent splitting up the specified list of windows into roughly equal work. Currently this is implemented by just splitting up into roughly equal numbers of windows in each chunk. | def _chunk_windows(windows, num_chunks):
if num_chunks <= 0 or int(num_chunks) != num_chunks:
raise ValueError("Number of chunks must be an integer > 0")
num_chunks = min(len(windows) - 1, num_chunks)
splits = np.array_split(windows[:-1], num_chunks)
chunks = []
for j... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_chunks(sequence, window_size, step=1):\n k = len(sequence)\n for i in range(0, k - window_size + 1, step):\n end = i + window_size\n chunk = sequence[i:i + window_size]\n assert len(chunk) == window_size\n yield chunk, end",
"def get_chunks(sequence, window_size, step=1)... | [
"0.71422964",
"0.69719464",
"0.6838129",
"0.68195677",
"0.68195146",
"0.68004143",
"0.6731537",
"0.67168945",
"0.66992015",
"0.6667279",
"0.6657442",
"0.6653202",
"0.6601734",
"0.6600378",
"0.6592009",
"0.6563785",
"0.6553596",
"0.65448177",
"0.65265995",
"0.6516239",
"0.6510... | 0.8617322 | 0 |
No windows were specified, so we can chunk up the whole genome by tree, and do a simple sum of the results. This means that we have to handle span_normalise specially, though. | def _parallelise_divmat_by_tree(self, num_threads, span_normalise, **kwargs):
def worker(interval):
return self._ll_tree_sequence.divergence_matrix(interval, **kwargs)
work = self._chunk_sequence_by_tree(num_threads)
with concurrent.futures.ThreadPoolExecutor(max_workers=num_thread... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def total_chunks(self) -> global___Expression:",
"def _parallelise_divmat_by_window(self, windows, num_threads, **kwargs):\n\n def worker(sub_windows):\n return self._ll_tree_sequence.divergence_matrix(sub_windows, **kwargs)\n\n work = self._chunk_windows(windows, num_threads)\n w... | [
"0.5622587",
"0.5214634",
"0.51100093",
"0.50179994",
"0.5017514",
"0.50097734",
"0.4967319",
"0.4967319",
"0.4967319",
"0.4967319",
"0.4967319",
"0.49596268",
"0.4951826",
"0.49516213",
"0.49353608",
"0.49171713",
"0.49077803",
"0.48997727",
"0.48599377",
"0.48536515",
"0.48... | 0.6275064 | 0 |
Computes genetic relatedness between (and within) pairs of sets of nodes from ``sample_sets``. Operates on ``k = 2`` sample sets at a time; please see the | def genetic_relatedness(
self,
sample_sets,
indexes=None,
windows=None,
mode="site",
span_normalise=True,
polarised=False,
proportion=True,
):
if proportion:
# TODO this should be done in C also
all_samples = list({u for... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __generate_random_nodes(self,k=3):\n if k < 3:\n k = 3\n\n k = min(k,len(self.G.nodes()))\n self.__logger.info(\"RANDOM_NODES: try to generate a set of {} nodes sampled with uniform distribution\".format(k))\n \n return random.sample(self.G.nodes(),k)",
"def ar_g... | [
"0.56016374",
"0.5574127",
"0.55174595",
"0.54053736",
"0.5296149",
"0.5209461",
"0.52043664",
"0.5146608",
"0.5080076",
"0.50706524",
"0.5052835",
"0.5052191",
"0.5041822",
"0.50326806",
"0.5018051",
"0.50145555",
"0.49817073",
"0.49463746",
"0.494107",
"0.49373287",
"0.4933... | 0.68275255 | 0 |
r""" Computes weighted genetic relatedness. If the kth pair of indices is (i, j) then the kth column of output will be | def genetic_relatedness_weighted(
self,
W,
indexes=None,
windows=None,
mode="site",
span_normalise=True,
polarised=False,
):
if len(W) != self.num_samples:
raise ValueError(
"First trait dimension must be equal to number of ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fitness(ind):\n return kNN.distance(ind),",
"def calculate_weighted_results():\n pass",
"def collect_weights(self, index, ranker):\n G_j = 0.\n if self.score_type == ScoreType.Independent:\n G_j = self.rankers[index].weights\n elif self.score_type == ScoreType.Full:\n ... | [
"0.62755966",
"0.611747",
"0.60366863",
"0.5914263",
"0.5912153",
"0.57885504",
"0.57649857",
"0.57568914",
"0.5733346",
"0.5632943",
"0.5607885",
"0.5596165",
"0.55847687",
"0.55819297",
"0.5573469",
"0.55677205",
"0.55567193",
"0.5546268",
"0.55425125",
"0.5542276",
"0.5529... | 0.66861045 | 0 |
Computes the mean squared correlations between each of the columns of ``W`` (the "phenotypes") and inheritance along the tree sequence. | def trait_correlation(self, W, windows=None, mode="site", span_normalise=True):
if W.shape[0] != self.num_samples:
raise ValueError(
"First trait dimension must be equal to number of samples."
)
sds = np.std(W, axis=0)
if np.any(sds == 0):
rais... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _mn_cor_ ( self , size = -1 , root = False ) :\n #\n cov = self.cov ( size , root )\n #\n from math import sqrt\n #\n if isinstance ( cov , ROOT.TMatrix ) :\n\n size = cov.GetNrows()\n root = True\n \n else : size = cov.kRows\n\n ## use ROOT matrices \n if r... | [
"0.55278707",
"0.533824",
"0.5323898",
"0.5276437",
"0.5222183",
"0.52056414",
"0.5171804",
"0.5141465",
"0.5050081",
"0.49698487",
"0.49314198",
"0.49182117",
"0.49008292",
"0.48973528",
"0.48424768",
"0.48410568",
"0.48295406",
"0.48280972",
"0.4806549",
"0.47901765",
"0.47... | 0.5804141 | 0 |
Computes the density of segregating sites for each of the sets of nodes from ``sample_sets``, and related quantities. | def segregating_sites(
self, sample_sets=None, windows=None, mode="site", span_normalise=True
):
return self.__one_way_sample_set_stat(
self._ll_tree_sequence.segregating_sites,
sample_sets,
windows=windows,
mode=mode,
span_normalise=span_n... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def Tajimas_D(self, sample_sets=None, windows=None, mode=\"site\"):\n\n # TODO this should be done in C as we'll want to support this method there.\n def tjd_func(sample_set_sizes, flattened, **kwargs):\n n = sample_set_sizes\n T = self.ll_tree_sequence.diversity(n, flattened, *... | [
"0.5737003",
"0.5658834",
"0.5629371",
"0.5444928",
"0.5441875",
"0.5267848",
"0.5154091",
"0.5097313",
"0.5078101",
"0.50757366",
"0.5071253",
"0.5026366",
"0.5018293",
"0.5009851",
"0.49478486",
"0.4945772",
"0.49068594",
"0.4890072",
"0.48899424",
"0.48826244",
"0.48456463... | 0.61776984 | 0 |
Computes the allele frequency spectrum (AFS) in windows across the genome for with respect to the specified ``sample_sets``. | def allele_frequency_spectrum(
self,
sample_sets=None,
windows=None,
mode="site",
span_normalise=True,
polarised=False,
):
if sample_sets is None:
sample_sets = [self.samples()]
return self.__one_way_sample_set_stat(
self._ll_tr... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def Fst(\n self, sample_sets, indexes=None, windows=None, mode=\"site\", span_normalise=True\n ):\n # TODO this should really be implemented in C (presumably C programmers will want\n # to compute Fst too), but in the mean time implementing using the low-level\n # calls has two advan... | [
"0.55099547",
"0.5447716",
"0.54216576",
"0.5416744",
"0.53818214",
"0.5361482",
"0.5258519",
"0.52265406",
"0.5209497",
"0.5155454",
"0.51440686",
"0.5122742",
"0.5102193",
"0.50156564",
"0.5004889",
"0.49970517",
"0.49772847",
"0.49682304",
"0.49637994",
"0.4953921",
"0.493... | 0.66451544 | 0 |
Computes Tajima's D of sets of nodes from ``sample_sets`` in windows. | def Tajimas_D(self, sample_sets=None, windows=None, mode="site"):
# TODO this should be done in C as we'll want to support this method there.
def tjd_func(sample_set_sizes, flattened, **kwargs):
n = sample_set_sizes
T = self.ll_tree_sequence.diversity(n, flattened, **kwargs)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def Fst(\n self, sample_sets, indexes=None, windows=None, mode=\"site\", span_normalise=True\n ):\n # TODO this should really be implemented in C (presumably C programmers will want\n # to compute Fst too), but in the mean time implementing using the low-level\n # calls has two advan... | [
"0.533044",
"0.5167808",
"0.51656663",
"0.51428396",
"0.5117673",
"0.5082707",
"0.50704175",
"0.50602657",
"0.5050364",
"0.5049091",
"0.50106055",
"0.4993974",
"0.49842837",
"0.4979484",
"0.49507374",
"0.4941758",
"0.49229553",
"0.48955372",
"0.48732674",
"0.4862238",
"0.4848... | 0.7572562 | 0 |
Computes "windowed" Fst between pairs of sets of nodes from ``sample_sets``. Operates on ``k = 2`` sample sets at a time; please see the | def Fst(
self, sample_sets, indexes=None, windows=None, mode="site", span_normalise=True
):
# TODO this should really be implemented in C (presumably C programmers will want
# to compute Fst too), but in the mean time implementing using the low-level
# calls has two advantages: (a) w... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def f2(\n self, sample_sets, indexes=None, windows=None, mode=\"site\", span_normalise=True\n ):\n return self.__k_way_sample_set_stat(\n self._ll_tree_sequence.f2,\n 2,\n sample_sets,\n indexes=indexes,\n windows=windows,\n mode=mo... | [
"0.60226196",
"0.58739316",
"0.5621082",
"0.54240835",
"0.53873813",
"0.5356835",
"0.5273418",
"0.52524877",
"0.5243462",
"0.5049993",
"0.4994892",
"0.4977813",
"0.49664733",
"0.495502",
"0.4949243",
"0.49161428",
"0.49016616",
"0.48593423",
"0.48593423",
"0.48370582",
"0.483... | 0.7042964 | 0 |
Computes the 'Y' statistic between triples of sets of nodes from ``sample_sets``. Operates on ``k = 3`` sample sets at a time; please see the | def Y3(
self, sample_sets, indexes=None, windows=None, mode="site", span_normalise=True
):
return self.__k_way_sample_set_stat(
self._ll_tree_sequence.Y3,
3,
sample_sets,
indexes=indexes,
windows=windows,
mode=mode,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def Y2(\n self, sample_sets, indexes=None, windows=None, mode=\"site\", span_normalise=True\n ):\n return self.__k_way_sample_set_stat(\n self._ll_tree_sequence.Y2,\n 2,\n sample_sets,\n indexes=indexes,\n windows=windows,\n mode=mo... | [
"0.6016686",
"0.54672503",
"0.53609645",
"0.5347947",
"0.53248024",
"0.5316184",
"0.53127843",
"0.523322",
"0.5173703",
"0.51656604",
"0.51344424",
"0.51267976",
"0.51038444",
"0.5102409",
"0.5096221",
"0.50845975",
"0.5081532",
"0.5060182",
"0.50377506",
"0.5030279",
"0.5017... | 0.5775093 | 1 |
Computes the 'Y2' statistic between pairs of sets of nodes from ``sample_sets``. Operates on ``k = 2`` sample sets at a time; please see the | def Y2(
self, sample_sets, indexes=None, windows=None, mode="site", span_normalise=True
):
return self.__k_way_sample_set_stat(
self._ll_tree_sequence.Y2,
2,
sample_sets,
indexes=indexes,
windows=windows,
mode=mode,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def f2(\n self, sample_sets, indexes=None, windows=None, mode=\"site\", span_normalise=True\n ):\n return self.__k_way_sample_set_stat(\n self._ll_tree_sequence.f2,\n 2,\n sample_sets,\n indexes=indexes,\n windows=windows,\n mode=mo... | [
"0.6148589",
"0.55073047",
"0.533685",
"0.5306504",
"0.5149028",
"0.5080732",
"0.49575803",
"0.48934448",
"0.48508647",
"0.48248103",
"0.48164037",
"0.48056015",
"0.47655475",
"0.4760167",
"0.4748487",
"0.47224978",
"0.46989775",
"0.46983868",
"0.4666418",
"0.4661498",
"0.463... | 0.7479811 | 0 |
Computes the 'Y1' statistic within each of the sets of nodes given by ``sample_sets``. | def Y1(self, sample_sets, windows=None, mode="site", span_normalise=True):
return self.__one_way_sample_set_stat(
self._ll_tree_sequence.Y1,
sample_sets,
windows=windows,
mode=mode,
span_normalise=span_normalise,
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def Y2(\n self, sample_sets, indexes=None, windows=None, mode=\"site\", span_normalise=True\n ):\n return self.__k_way_sample_set_stat(\n self._ll_tree_sequence.Y2,\n 2,\n sample_sets,\n indexes=indexes,\n windows=windows,\n mode=mo... | [
"0.6242391",
"0.5483612",
"0.53615",
"0.5355459",
"0.5305698",
"0.5207772",
"0.5165038",
"0.5055484",
"0.49833578",
"0.49650386",
"0.49621442",
"0.4946625",
"0.49221393",
"0.49208057",
"0.4911203",
"0.490989",
"0.48838988",
"0.48728168",
"0.48600656",
"0.48272294",
"0.4821055... | 0.7848549 | 0 |
Computes Patterson's f4 statistic between four groups of nodes from ``sample_sets``. Operates on ``k = 4`` sample sets at a time; please see the | def f4(
self, sample_sets, indexes=None, windows=None, mode="site", span_normalise=True
):
return self.__k_way_sample_set_stat(
self._ll_tree_sequence.f4,
4,
sample_sets,
indexes=indexes,
windows=windows,
mode=mode,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def k_fold_cross_validation_populationwise(self, K: int=5, rem_day4:bool=True, smote:bool=True, shuffle: bool=False) -> dict:\n counter = 0\n results = {}\n for df in self.dataframes:\n k_folds = {}\n\n header = set(df['label'].tolist())\n # Removing Day 4\n ... | [
"0.5157142",
"0.5035221",
"0.498841",
"0.49321067",
"0.4918656",
"0.4910453",
"0.4865095",
"0.4845607",
"0.4818677",
"0.47737154",
"0.47437426",
"0.4732812",
"0.47311416",
"0.47190532",
"0.4714793",
"0.47098234",
"0.4705546",
"0.46898577",
"0.46896797",
"0.46638462",
"0.46523... | 0.7104194 | 0 |
r""" Computes Patterson's f3 statistic between three groups of nodes from ``sample_sets``. | def f3(
self, sample_sets, indexes=None, windows=None, mode="site", span_normalise=True
):
return self.__k_way_sample_set_stat(
self._ll_tree_sequence.f3,
3,
sample_sets,
indexes=indexes,
windows=windows,
mode=mode,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def Y3(\n self, sample_sets, indexes=None, windows=None, mode=\"site\", span_normalise=True\n ):\n return self.__k_way_sample_set_stat(\n self._ll_tree_sequence.Y3,\n 3,\n sample_sets,\n indexes=indexes,\n windows=windows,\n mode=mo... | [
"0.5953976",
"0.55879056",
"0.5529968",
"0.54743695",
"0.54087",
"0.53779805",
"0.53688484",
"0.5294506",
"0.5230663",
"0.5229311",
"0.52109444",
"0.5200102",
"0.5176864",
"0.51692283",
"0.51482946",
"0.5114727",
"0.5089363",
"0.50861484",
"0.5054133",
"0.5046256",
"0.5037876... | 0.73561776 | 0 |
Computes Patterson's f2 statistic between two groups of nodes from ``sample_sets``. Operates on ``k = 2`` sample sets at a time; please see the | def f2(
self, sample_sets, indexes=None, windows=None, mode="site", span_normalise=True
):
return self.__k_way_sample_set_stat(
self._ll_tree_sequence.f2,
2,
sample_sets,
indexes=indexes,
windows=windows,
mode=mode,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _ks_2samp_fast(prepared_data1, data2, prepared_weights1, weights2, F1):\n indices = numpy.searchsorted(prepared_data1, data2)\n weights2 /= numpy.sum(weights2)\n prepared_weights2 = numpy.bincount(indices, weights=weights2, minlength=len(prepared_data1))\n F2 = compute_cdf(prepared_weights2)\n r... | [
"0.5441867",
"0.5359403",
"0.53172636",
"0.5312422",
"0.5264731",
"0.5261833",
"0.5191983",
"0.5189591",
"0.5175254",
"0.51591474",
"0.5080447",
"0.5027782",
"0.49659964",
"0.49574408",
"0.49227247",
"0.48958516",
"0.4892362",
"0.48726776",
"0.48600957",
"0.48472035",
"0.4844... | 0.6739702 | 0 |
Computes for every node the mean number of samples in each of the `sample_sets` that descend from that node, averaged over the portions of the genome for which the node is ancestral to any sample. The output is an array, `C[node, j]`, which reports the total span of all genomes in `sample_sets[j]` that inherit from `no... | def mean_descendants(self, sample_sets):
return self._ll_tree_sequence.mean_descendants(sample_sets) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def divergence(\n self, sample_sets, indexes=None, windows=None, mode=\"site\", span_normalise=True\n ):\n return self.__k_way_sample_set_stat(\n self._ll_tree_sequence.divergence,\n 2,\n sample_sets,\n indexes=indexes,\n windows=windows,\n ... | [
"0.53171337",
"0.51711434",
"0.5151091",
"0.51106817",
"0.50872517",
"0.50750244",
"0.50644344",
"0.5043244",
"0.5036893",
"0.50316507",
"0.5020908",
"0.49549758",
"0.49234363",
"0.49170566",
"0.48717785",
"0.4860556",
"0.4859718",
"0.4851361",
"0.4843177",
"0.48272172",
"0.4... | 0.67898303 | 0 |
Returns the pairwise nucleotide site diversity, the average number of sites that differ between a every possible pair of distinct samples. If `samples` is specified, calculate the diversity within this set. | def pairwise_diversity(self, samples=None):
if samples is None:
samples = self.samples()
return float(
self.diversity(
[samples], windows=[0, self.sequence_length], span_normalise=False
)[0]
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pairwise_diversity(calls):\n # Count up the number of reference and alternate genotypes.\n if 0 in calls:\n ref_count = calls.count(0)\n else:\n return 0\n if 1 in calls:\n alt_count = calls.count(1)\n else:\n return 0\n # This sample size will change depending... | [
"0.6356381",
"0.6344593",
"0.61458546",
"0.611544",
"0.56918055",
"0.5529563",
"0.54415536",
"0.5331187",
"0.5186065",
"0.5158477",
"0.5146702",
"0.5131651",
"0.51299274",
"0.51145804",
"0.5107346",
"0.509397",
"0.5092142",
"0.50767106",
"0.50545603",
"0.5050361",
"0.5036594"... | 0.7534534 | 0 |
Write ``ms`` formatted output from the genotypes of a tree sequence | def write_ms(
tree_sequence,
output,
print_trees=False,
precision=4,
num_replicates=1,
write_header=True,
):
if not isinstance(tree_sequence, collections.abc.Iterable):
tree_sequence = [tree_sequence]
i = 0
for tree_seq in tree_sequence:
if i > 0:
write_h... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def printGeneTree(self):\n align = AlignIO.read(self.newPhylip, 'phylip') # Reads created .phy file containing the SeqRecord\n #print (align) # prints concatenated allignments\n calculator = DistanceCalculator('identity')\n dm = calculator.get_distance(align)# Calculate the distance ma... | [
"0.604203",
"0.56569207",
"0.5604279",
"0.55419624",
"0.55216753",
"0.5485705",
"0.5462621",
"0.5439612",
"0.5438816",
"0.5433295",
"0.5431748",
"0.5430604",
"0.5412434",
"0.53899467",
"0.53512967",
"0.53354084",
"0.5312338",
"0.5265731",
"0.5231917",
"0.5191932",
"0.51905894... | 0.71283454 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.