Module genealloy.genealloy
View Source
from .codontable import (
codon_to_aa,
aa_to_codon_extended,
codon_extended_to_aa,
complement_table,
compare_letters,
)
def convert_seq_to_codons(seq):
"""Convert a string (sequence) into a list of 3-letter strings (triplets)."""
seq_codons = [seq[i : i + 3] for i in range(0, len(seq), 3)]
return seq_codons
def convert_codonlist_to_tuplelist(seq_codons, codon_to_codon_extended):
"""Convert a list of triplets into a list of tuples, using a swaptable.
The swaptable is a dict of triplet: triplets, and determines the
allowed swaps.
"""
codon_extended = [None] * len(seq_codons)
for i, codon in enumerate(seq_codons):
codon_extended[i] = codon_to_codon_extended[codon]
return codon_extended
def get_next_letter(sequence_tuplelist, current_letter_index):
"""Get next letter in the sequence."""
letter_index = current_letter_index
if current_letter_index[2] == 2:
# last letter of triplet, advance to next codon:
letter_index = [letter_index[0] + 1, 0, 0]
try:
i, j, k = letter_index[0], letter_index[1], letter_index[2]
letter = (sequence_tuplelist[i][j][k], letter_index)
return letter
except:
raise
else:
# letter is not the last in triplet, get the next one:
letter_index[2] = letter_index[2] + 1
i, j, k = letter_index[0], letter_index[1], letter_index[2]
letter = (sequence_tuplelist[i][j][k], letter_index)
return letter
def get_letter_in_next_triplet(sequence_tuplelist, current_letter_index):
"""Get first letter in the next triplet."""
letter_index = current_letter_index
letter_index[1] = letter_index[1] + 1 # triplet position
letter_index[2] = 0 # move letter position to triplet's first letter
try:
i, j, k = letter_index[0], letter_index[1], letter_index[2]
letter = (sequence_tuplelist[i][j][k], letter_index)
return letter
except:
raise
def compare_then_get_letter_recursively(
host_tuplelist, parasite_tuplelist, host_letter, parasite_letter
):
"""Compare two letters then get next pair of letters recursively.
Returns string for match or no match between the sequences.
"""
# This function works only for in-frame comparisons and is given the first
# letters of the host and parasite sequences. If the two letters match,
# then gets the next parasite and host letters, and calls itself.
# If can't get next parasite letter, then the comparison has finished
# and a full match has been found.
# If letters do not match, then gets the next parasite triplet and calls
# itself; if there are no more parasite triplets, it gets the next host
# triplet and calls itself. If there are no more host triplets, then there is
# no match between the sequences.
is_match = compare_letters(host_letter[0], parasite_letter[0])
if is_match:
try:
next_parasite_letter = get_next_letter(
parasite_tuplelist, parasite_letter[1]
)
except:
return str(
"Finished parasite sequence, match found! Ending host position:"
+ str(host_letter[1])
)
else:
next_host_letter = get_next_letter(
host_tuplelist, host_letter[1]
) # always OK
return compare_then_get_letter_recursively(
host_tuplelist,
parasite_tuplelist,
next_host_letter,
next_parasite_letter,
)
else: # letters do not match, move on to next parasite triplet
try:
next_parasite_letter = get_letter_in_next_triplet(
parasite_tuplelist, parasite_letter[1]
)
except: # no more parasite triplet, get next host
try:
next_host_letter = get_letter_in_next_triplet(
host_tuplelist, host_letter[1]
)
except:
return "No match for this starting codon position"
else:
i = parasite_letter[1][0] # same codon
j, k = 0, 0 # reset parasite to first triplet, first letter
next_parasite_letter = (parasite_tuplelist[i][j][k], [i, j, k])
return compare_then_get_letter_recursively(
host_tuplelist,
parasite_tuplelist,
next_host_letter,
next_parasite_letter,
)
else:
i, j = host_letter[1][0], host_letter[1][1] # same codon, same triplet
k = 0 # reset host letter to beginning of triplet because parasite was reset
next_host_letter = (host_tuplelist[i][j][k], [i, j, k])
return compare_then_get_letter_recursively(
host_tuplelist,
parasite_tuplelist,
next_host_letter,
next_parasite_letter,
)
def walk_seqstep(seqstep):
"""Compare two sequences by calling `advance_step` until it returns the result."""
while not seqstep.result:
seqstep.advance_step()
def compare_sequence_tuplelists(parasite_tuplelist, host_tuplelist, frameshift):
"""Compare two sequence's tuplists for given frame and return list of matches."""
len_parasite = len(parasite_tuplelist)
len_host = len(host_tuplelist)
list_of_matches = []
for start_host_codon in range(0, len_host - len_parasite + 1):
seqstep = SeqStep(
host_tuplelist,
parasite_tuplelist,
start_host_codon=start_host_codon,
frameshift=frameshift,
)
walk_seqstep(seqstep)
if seqstep.match:
list_of_matches.append(start_host_codon)
return list_of_matches
def compare_sequence_tuplelists_in_all_frames(
parasite_tuplelist, host_tuplelist, prefix=""
):
"""Compare two sequence's tuplists for all frames and return dict of matches."""
results_for_all_frames = dict()
for frameshift in [0, 1, 2]:
result = compare_sequence_tuplelists(
parasite_tuplelist, host_tuplelist, frameshift
)
key = prefix + str(frameshift)
results_for_all_frames[key] = result
return results_for_all_frames
def find_partial_overlaps(host, parasite, swaptable, verbose=True):
flank = len(parasite) * "N"
host_flank = flank + host + flank
swaptable["NNN"] = ("NNN",)
result = make_genealloy(host_flank, parasite, swaptable, verbose=True)
return result
def make_genealloy(host, parasite, swaptable, verbose=True):
"""Compare two sequence strings and return dictionary of matches."""
host_codons = convert_seq_to_codons(host)
host_tuplelist = convert_codonlist_to_tuplelist(host_codons, swaptable)
parasite_codons = convert_seq_to_codons(parasite)
parasite_tuplelist = convert_codonlist_to_tuplelist(parasite_codons, swaptable)
forward_results = compare_sequence_tuplelists_in_all_frames(
parasite_tuplelist, host_tuplelist, prefix="f_"
)
reverse_complement_tuplelist = get_reverse_complement_tuplelist(host_tuplelist)
reverse_complement_results = compare_sequence_tuplelists_in_all_frames(
parasite_tuplelist, reverse_complement_tuplelist, prefix="rc_"
)
result = forward_results.copy()
result.update(reverse_complement_results)
if verbose:
if all(value == [] for value in result.values()):
print("These sequences cannot be mixed")
else:
print("A genealloy can be made using these sequences!")
return result
def get_complement_tuplelist(codon_tuplelist):
"""Get complement triplets of a sequence tuplelist."""
complement_tuplelist = []
for index, codon in enumerate(codon_tuplelist):
complement_tripletlist = []
for triplet in codon:
letter1 = triplet[0]
letter2 = triplet[1]
letter3 = triplet[2]
complement_triplet = (
complement_table[letter1]
+ complement_table[letter2]
+ complement_table[letter3]
)
complement_tripletlist.append(complement_triplet)
complement_codon = tuple(complement_tripletlist)
complement_tuplelist.append(complement_codon)
return complement_tuplelist
def get_reverse_tuplelist(codon_tuplelist):
"""Get reverse of a tuplelist with reversed triplets."""
reverse_tuplelist = []
for codon in reversed(codon_tuplelist):
reverse_tripletlist = []
for triplet in codon:
reverse_triplet = triplet[::-1]
reverse_tripletlist.append(reverse_triplet)
reverse_codon = tuple(reverse_tripletlist)
reverse_tuplelist.append(reverse_codon)
return reverse_tuplelist
def get_reverse_complement_tuplelist(codon_tuplelist):
"""Get reverse complement of a sequence's tuplelist."""
complement_tuplelist = get_complement_tuplelist(codon_tuplelist)
reverse_complement_tuplelist = get_reverse_tuplelist(complement_tuplelist)
return reverse_complement_tuplelist
class Duodon:
"""Class for storing two triplets"""
def __init__(self, first_triplet, second_triplet):
self.first_triplet = first_triplet
self.second_triplet = second_triplet
class SeqStep:
"""Class for keeping track of sequence comparison
It stores a method that aligns a parasite triplet with two consecutive host
triplets (duodons), a cursor that marks the position of the comparison process,
and methods for generating duodons and comparing them with triplets.
The `advance_step()` method attempts to advance the comparison by one codon
step. It can (i) advance the cursor or (ii) conclude that there is no match
between the sequences, or (iii) conclude that there is a match.
Parameters
----------
host_tuplelist
A list of tuples. Each tuple stores the allowed triplets for a codon
position of the host sequence.
parasite_tuplelist
A list of tuples. Each tuple stores the allowed triplets for a codon
position of the parasite sequence.
frameshift
An integer (0, 1 or 2) denoting the frameshift between host and parasite.
start_host_codon
The host codon position from which the comparison should start.
"""
def __init__(
self, host_tuplelist, parasite_tuplelist, frameshift=0, start_host_codon=0
):
self.host_tuplelist = host_tuplelist
self.parasite_tuplelist = parasite_tuplelist
self.frameshift = frameshift
self.start_host_codon = start_host_codon
self.cursor = 0
self.len_parasite = len(parasite_tuplelist)
self.len_host = len(host_tuplelist)
self.parasite_path = []
self.host_path = []
self.match = False
self.result = None
def generate_duodons(self):
self.cursor
self.start_host_codon
duodons = []
host_codon = self.start_host_codon + self.cursor
if self.host_path == []: # first time it's made
for triplet_1 in self.host_tuplelist[host_codon]:
for triplet_2 in self.host_tuplelist[host_codon + 1]:
duodons.append(Duodon(triplet_1, triplet_2))
else:
triplet_1 = self.host_path[-1].second_triplet # of last used duodon
try:
for triplet_2 in self.host_tuplelist[host_codon + 1]:
duodons.append(Duodon(triplet_1, triplet_2))
except:
duodons.append(Duodon(triplet_1, "NNN"))
return duodons
def return_all_matching_duodons(self, triplet, duodons, frameshift=0):
matching_duodons = []
for duodon in duodons:
host_letters = duodon.first_triplet + duodon.second_triplet
# compare 1st letter:
if not compare_letters(host_letters[0 + frameshift], triplet[0]):
continue
if not compare_letters(host_letters[1 + frameshift], triplet[1]):
continue
if not compare_letters(host_letters[2 + frameshift], triplet[2]):
continue
matching_duodons.append(duodon)
return matching_duodons
def compare_triplet_and_duodon(self, triplet, duodon, frameshift=0):
host_letters = duodon.first_triplet + duodon.second_triplet
if not compare_letters(host_letters[0 + frameshift], triplet[0]):
return False
if not compare_letters(host_letters[1 + frameshift], triplet[1]):
return False
if not compare_letters(host_letters[2 + frameshift], triplet[2]):
return False
return True
def advance_step(self):
if self.result:
return self.result
if self.cursor == self.len_parasite:
self.match = True
self.result = (
"Match found between parasite and host sequence. Start codon was: "
+ str(self.start_host_codon)
)
return self.result
parasite_triplets = list(self.parasite_tuplelist[self.cursor])
host_duodons = self.generate_duodons()
while True:
try:
parasite_triplet = parasite_triplets[0]
except:
self.result = "Sequences don't match. Start codon was: " + str(
self.start_host_codon
)
return self.result
else:
host_duodons_for_parasite_triplet = host_duodons[:]
host_duodons_for_parasite_triplet = self.return_all_matching_duodons(
parasite_triplet,
host_duodons_for_parasite_triplet,
frameshift=self.frameshift,
)
self.parasite_path.append(parasite_triplet)
while True:
try:
host_doudon = host_duodons_for_parasite_triplet[0]
except:
self.parasite_path.pop()
del parasite_triplets[0]
break
else:
if self.compare_triplet_and_duodon(
parasite_triplet, host_doudon, frameshift=self.frameshift
):
self.host_path.append(host_doudon)
self.cursor += 1
return "Codon matched, cursor advanced"
else:
del host_duodons_for_parasite_triplet[0]
Variables
aa_to_codon_extended
codon_extended_to_aa
codon_to_aa
complement_table
Functions
compare_sequence_tuplelists
def compare_sequence_tuplelists(
parasite_tuplelist,
host_tuplelist,
frameshift
)
Compare two sequence's tuplists for given frame and return list of matches.
View Source
def compare_sequence_tuplelists(parasite_tuplelist, host_tuplelist, frameshift):
"""Compare two sequence's tuplists for given frame and return list of matches."""
len_parasite = len(parasite_tuplelist)
len_host = len(host_tuplelist)
list_of_matches = []
for start_host_codon in range(0, len_host - len_parasite + 1):
seqstep = SeqStep(
host_tuplelist,
parasite_tuplelist,
start_host_codon=start_host_codon,
frameshift=frameshift,
)
walk_seqstep(seqstep)
if seqstep.match:
list_of_matches.append(start_host_codon)
return list_of_matches
compare_sequence_tuplelists_in_all_frames
def compare_sequence_tuplelists_in_all_frames(
parasite_tuplelist,
host_tuplelist,
prefix=''
)
Compare two sequence's tuplists for all frames and return dict of matches.
View Source
def compare_sequence_tuplelists_in_all_frames(
parasite_tuplelist, host_tuplelist, prefix=""
):
"""Compare two sequence's tuplists for all frames and return dict of matches."""
results_for_all_frames = dict()
for frameshift in [0, 1, 2]:
result = compare_sequence_tuplelists(
parasite_tuplelist, host_tuplelist, frameshift
)
key = prefix + str(frameshift)
results_for_all_frames[key] = result
return results_for_all_frames
compare_then_get_letter_recursively
def compare_then_get_letter_recursively(
host_tuplelist,
parasite_tuplelist,
host_letter,
parasite_letter
)
Compare two letters then get next pair of letters recursively.
Returns string for match or no match between the sequences.
View Source
def compare_then_get_letter_recursively(
host_tuplelist, parasite_tuplelist, host_letter, parasite_letter
):
"""Compare two letters then get next pair of letters recursively.
Returns string for match or no match between the sequences.
"""
# This function works only for in-frame comparisons and is given the first
# letters of the host and parasite sequences. If the two letters match,
# then gets the next parasite and host letters, and calls itself.
# If can't get next parasite letter, then the comparison has finished
# and a full match has been found.
# If letters do not match, then gets the next parasite triplet and calls
# itself; if there are no more parasite triplets, it gets the next host
# triplet and calls itself. If there are no more host triplets, then there is
# no match between the sequences.
is_match = compare_letters(host_letter[0], parasite_letter[0])
if is_match:
try:
next_parasite_letter = get_next_letter(
parasite_tuplelist, parasite_letter[1]
)
except:
return str(
"Finished parasite sequence, match found! Ending host position:"
+ str(host_letter[1])
)
else:
next_host_letter = get_next_letter(
host_tuplelist, host_letter[1]
) # always OK
return compare_then_get_letter_recursively(
host_tuplelist,
parasite_tuplelist,
next_host_letter,
next_parasite_letter,
)
else: # letters do not match, move on to next parasite triplet
try:
next_parasite_letter = get_letter_in_next_triplet(
parasite_tuplelist, parasite_letter[1]
)
except: # no more parasite triplet, get next host
try:
next_host_letter = get_letter_in_next_triplet(
host_tuplelist, host_letter[1]
)
except:
return "No match for this starting codon position"
else:
i = parasite_letter[1][0] # same codon
j, k = 0, 0 # reset parasite to first triplet, first letter
next_parasite_letter = (parasite_tuplelist[i][j][k], [i, j, k])
return compare_then_get_letter_recursively(
host_tuplelist,
parasite_tuplelist,
next_host_letter,
next_parasite_letter,
)
else:
i, j = host_letter[1][0], host_letter[1][1] # same codon, same triplet
k = 0 # reset host letter to beginning of triplet because parasite was reset
next_host_letter = (host_tuplelist[i][j][k], [i, j, k])
return compare_then_get_letter_recursively(
host_tuplelist,
parasite_tuplelist,
next_host_letter,
next_parasite_letter,
)
convert_codonlist_to_tuplelist
def convert_codonlist_to_tuplelist(
seq_codons,
codon_to_codon_extended
)
Convert a list of triplets into a list of tuples, using a swaptable.
The swaptable is a dict of triplet: triplets, and determines the allowed swaps.
View Source
def convert_codonlist_to_tuplelist(seq_codons, codon_to_codon_extended):
"""Convert a list of triplets into a list of tuples, using a swaptable.
The swaptable is a dict of triplet: triplets, and determines the
allowed swaps.
"""
codon_extended = [None] * len(seq_codons)
for i, codon in enumerate(seq_codons):
codon_extended[i] = codon_to_codon_extended[codon]
return codon_extended
convert_seq_to_codons
def convert_seq_to_codons(
seq
)
Convert a string (sequence) into a list of 3-letter strings (triplets).
View Source
def convert_seq_to_codons(seq):
"""Convert a string (sequence) into a list of 3-letter strings (triplets)."""
seq_codons = [seq[i : i + 3] for i in range(0, len(seq), 3)]
return seq_codons
find_partial_overlaps
def find_partial_overlaps(
host,
parasite,
swaptable,
verbose=True
)
View Source
def find_partial_overlaps(host, parasite, swaptable, verbose=True):
flank = len(parasite) * "N"
host_flank = flank + host + flank
swaptable["NNN"] = ("NNN",)
result = make_genealloy(host_flank, parasite, swaptable, verbose=True)
return result
get_complement_tuplelist
def get_complement_tuplelist(
codon_tuplelist
)
Get complement triplets of a sequence tuplelist.
View Source
def get_complement_tuplelist(codon_tuplelist):
"""Get complement triplets of a sequence tuplelist."""
complement_tuplelist = []
for index, codon in enumerate(codon_tuplelist):
complement_tripletlist = []
for triplet in codon:
letter1 = triplet[0]
letter2 = triplet[1]
letter3 = triplet[2]
complement_triplet = (
complement_table[letter1]
+ complement_table[letter2]
+ complement_table[letter3]
)
complement_tripletlist.append(complement_triplet)
complement_codon = tuple(complement_tripletlist)
complement_tuplelist.append(complement_codon)
return complement_tuplelist
get_letter_in_next_triplet
def get_letter_in_next_triplet(
sequence_tuplelist,
current_letter_index
)
Get first letter in the next triplet.
View Source
def get_letter_in_next_triplet(sequence_tuplelist, current_letter_index):
"""Get first letter in the next triplet."""
letter_index = current_letter_index
letter_index[1] = letter_index[1] + 1 # triplet position
letter_index[2] = 0 # move letter position to triplet's first letter
try:
i, j, k = letter_index[0], letter_index[1], letter_index[2]
letter = (sequence_tuplelist[i][j][k], letter_index)
return letter
except:
raise
get_next_letter
def get_next_letter(
sequence_tuplelist,
current_letter_index
)
Get next letter in the sequence.
View Source
def get_next_letter(sequence_tuplelist, current_letter_index):
"""Get next letter in the sequence."""
letter_index = current_letter_index
if current_letter_index[2] == 2:
# last letter of triplet, advance to next codon:
letter_index = [letter_index[0] + 1, 0, 0]
try:
i, j, k = letter_index[0], letter_index[1], letter_index[2]
letter = (sequence_tuplelist[i][j][k], letter_index)
return letter
except:
raise
else:
# letter is not the last in triplet, get the next one:
letter_index[2] = letter_index[2] + 1
i, j, k = letter_index[0], letter_index[1], letter_index[2]
letter = (sequence_tuplelist[i][j][k], letter_index)
return letter
get_reverse_complement_tuplelist
def get_reverse_complement_tuplelist(
codon_tuplelist
)
Get reverse complement of a sequence's tuplelist.
View Source
def get_reverse_complement_tuplelist(codon_tuplelist):
"""Get reverse complement of a sequence's tuplelist."""
complement_tuplelist = get_complement_tuplelist(codon_tuplelist)
reverse_complement_tuplelist = get_reverse_tuplelist(complement_tuplelist)
return reverse_complement_tuplelist
get_reverse_tuplelist
def get_reverse_tuplelist(
codon_tuplelist
)
Get reverse of a tuplelist with reversed triplets.
View Source
def get_reverse_tuplelist(codon_tuplelist):
"""Get reverse of a tuplelist with reversed triplets."""
reverse_tuplelist = []
for codon in reversed(codon_tuplelist):
reverse_tripletlist = []
for triplet in codon:
reverse_triplet = triplet[::-1]
reverse_tripletlist.append(reverse_triplet)
reverse_codon = tuple(reverse_tripletlist)
reverse_tuplelist.append(reverse_codon)
return reverse_tuplelist
make_genealloy
def make_genealloy(
host,
parasite,
swaptable,
verbose=True
)
Compare two sequence strings and return dictionary of matches.
View Source
def make_genealloy(host, parasite, swaptable, verbose=True):
"""Compare two sequence strings and return dictionary of matches."""
host_codons = convert_seq_to_codons(host)
host_tuplelist = convert_codonlist_to_tuplelist(host_codons, swaptable)
parasite_codons = convert_seq_to_codons(parasite)
parasite_tuplelist = convert_codonlist_to_tuplelist(parasite_codons, swaptable)
forward_results = compare_sequence_tuplelists_in_all_frames(
parasite_tuplelist, host_tuplelist, prefix="f_"
)
reverse_complement_tuplelist = get_reverse_complement_tuplelist(host_tuplelist)
reverse_complement_results = compare_sequence_tuplelists_in_all_frames(
parasite_tuplelist, reverse_complement_tuplelist, prefix="rc_"
)
result = forward_results.copy()
result.update(reverse_complement_results)
if verbose:
if all(value == [] for value in result.values()):
print("These sequences cannot be mixed")
else:
print("A genealloy can be made using these sequences!")
return result
walk_seqstep
def walk_seqstep(
seqstep
)
Compare two sequences by calling advance_step
until it returns the result.
View Source
def walk_seqstep(seqstep):
"""Compare two sequences by calling `advance_step` until it returns the result."""
while not seqstep.result:
seqstep.advance_step()
Classes
Duodon
class Duodon(
first_triplet,
second_triplet
)
Class for storing two triplets
View Source
class Duodon:
"""Class for storing two triplets"""
def __init__(self, first_triplet, second_triplet):
self.first_triplet = first_triplet
self.second_triplet = second_triplet
SeqStep
class SeqStep(
host_tuplelist,
parasite_tuplelist,
frameshift=0,
start_host_codon=0
)
Class for keeping track of sequence comparison
It stores a method that aligns a parasite triplet with two consecutive host
triplets (duodons), a cursor that marks the position of the comparison process,
and methods for generating duodons and comparing them with triplets.
The advance_step()
method attempts to advance the comparison by one codon
step. It can (i) advance the cursor or (ii) conclude that there is no match
between the sequences, or (iii) conclude that there is a match.
Parameters
host_tuplelist A list of tuples. Each tuple stores the allowed triplets for a codon position of the host sequence.
parasite_tuplelist A list of tuples. Each tuple stores the allowed triplets for a codon position of the parasite sequence.
frameshift An integer (0, 1 or 2) denoting the frameshift between host and parasite.
start_host_codon The host codon position from which the comparison should start.
View Source
class SeqStep:
"""Class for keeping track of sequence comparison
It stores a method that aligns a parasite triplet with two consecutive host
triplets (duodons), a cursor that marks the position of the comparison process,
and methods for generating duodons and comparing them with triplets.
The `advance_step()` method attempts to advance the comparison by one codon
step. It can (i) advance the cursor or (ii) conclude that there is no match
between the sequences, or (iii) conclude that there is a match.
Parameters
----------
host_tuplelist
A list of tuples. Each tuple stores the allowed triplets for a codon
position of the host sequence.
parasite_tuplelist
A list of tuples. Each tuple stores the allowed triplets for a codon
position of the parasite sequence.
frameshift
An integer (0, 1 or 2) denoting the frameshift between host and parasite.
start_host_codon
The host codon position from which the comparison should start.
"""
def __init__(
self, host_tuplelist, parasite_tuplelist, frameshift=0, start_host_codon=0
):
self.host_tuplelist = host_tuplelist
self.parasite_tuplelist = parasite_tuplelist
self.frameshift = frameshift
self.start_host_codon = start_host_codon
self.cursor = 0
self.len_parasite = len(parasite_tuplelist)
self.len_host = len(host_tuplelist)
self.parasite_path = []
self.host_path = []
self.match = False
self.result = None
def generate_duodons(self):
self.cursor
self.start_host_codon
duodons = []
host_codon = self.start_host_codon + self.cursor
if self.host_path == []: # first time it's made
for triplet_1 in self.host_tuplelist[host_codon]:
for triplet_2 in self.host_tuplelist[host_codon + 1]:
duodons.append(Duodon(triplet_1, triplet_2))
else:
triplet_1 = self.host_path[-1].second_triplet # of last used duodon
try:
for triplet_2 in self.host_tuplelist[host_codon + 1]:
duodons.append(Duodon(triplet_1, triplet_2))
except:
duodons.append(Duodon(triplet_1, "NNN"))
return duodons
def return_all_matching_duodons(self, triplet, duodons, frameshift=0):
matching_duodons = []
for duodon in duodons:
host_letters = duodon.first_triplet + duodon.second_triplet
# compare 1st letter:
if not compare_letters(host_letters[0 + frameshift], triplet[0]):
continue
if not compare_letters(host_letters[1 + frameshift], triplet[1]):
continue
if not compare_letters(host_letters[2 + frameshift], triplet[2]):
continue
matching_duodons.append(duodon)
return matching_duodons
def compare_triplet_and_duodon(self, triplet, duodon, frameshift=0):
host_letters = duodon.first_triplet + duodon.second_triplet
if not compare_letters(host_letters[0 + frameshift], triplet[0]):
return False
if not compare_letters(host_letters[1 + frameshift], triplet[1]):
return False
if not compare_letters(host_letters[2 + frameshift], triplet[2]):
return False
return True
def advance_step(self):
if self.result:
return self.result
if self.cursor == self.len_parasite:
self.match = True
self.result = (
"Match found between parasite and host sequence. Start codon was: "
+ str(self.start_host_codon)
)
return self.result
parasite_triplets = list(self.parasite_tuplelist[self.cursor])
host_duodons = self.generate_duodons()
while True:
try:
parasite_triplet = parasite_triplets[0]
except:
self.result = "Sequences don't match. Start codon was: " + str(
self.start_host_codon
)
return self.result
else:
host_duodons_for_parasite_triplet = host_duodons[:]
host_duodons_for_parasite_triplet = self.return_all_matching_duodons(
parasite_triplet,
host_duodons_for_parasite_triplet,
frameshift=self.frameshift,
)
self.parasite_path.append(parasite_triplet)
while True:
try:
host_doudon = host_duodons_for_parasite_triplet[0]
except:
self.parasite_path.pop()
del parasite_triplets[0]
break
else:
if self.compare_triplet_and_duodon(
parasite_triplet, host_doudon, frameshift=self.frameshift
):
self.host_path.append(host_doudon)
self.cursor += 1
return "Codon matched, cursor advanced"
else:
del host_duodons_for_parasite_triplet[0]
Methods
advance_step
def advance_step(
self
)
View Source
def advance_step(self):
if self.result:
return self.result
if self.cursor == self.len_parasite:
self.match = True
self.result = (
"Match found between parasite and host sequence. Start codon was: "
+ str(self.start_host_codon)
)
return self.result
parasite_triplets = list(self.parasite_tuplelist[self.cursor])
host_duodons = self.generate_duodons()
while True:
try:
parasite_triplet = parasite_triplets[0]
except:
self.result = "Sequences don't match. Start codon was: " + str(
self.start_host_codon
)
return self.result
else:
host_duodons_for_parasite_triplet = host_duodons[:]
host_duodons_for_parasite_triplet = self.return_all_matching_duodons(
parasite_triplet,
host_duodons_for_parasite_triplet,
frameshift=self.frameshift,
)
self.parasite_path.append(parasite_triplet)
while True:
try:
host_doudon = host_duodons_for_parasite_triplet[0]
except:
self.parasite_path.pop()
del parasite_triplets[0]
break
else:
if self.compare_triplet_and_duodon(
parasite_triplet, host_doudon, frameshift=self.frameshift
):
self.host_path.append(host_doudon)
self.cursor += 1
return "Codon matched, cursor advanced"
else:
del host_duodons_for_parasite_triplet[0]
compare_triplet_and_duodon
def compare_triplet_and_duodon(
self,
triplet,
duodon,
frameshift=0
)
View Source
def compare_triplet_and_duodon(self, triplet, duodon, frameshift=0):
host_letters = duodon.first_triplet + duodon.second_triplet
if not compare_letters(host_letters[0 + frameshift], triplet[0]):
return False
if not compare_letters(host_letters[1 + frameshift], triplet[1]):
return False
if not compare_letters(host_letters[2 + frameshift], triplet[2]):
return False
return True
generate_duodons
def generate_duodons(
self
)
View Source
def generate_duodons(self):
self.cursor
self.start_host_codon
duodons = []
host_codon = self.start_host_codon + self.cursor
if self.host_path == []: # first time it's made
for triplet_1 in self.host_tuplelist[host_codon]:
for triplet_2 in self.host_tuplelist[host_codon + 1]:
duodons.append(Duodon(triplet_1, triplet_2))
else:
triplet_1 = self.host_path[-1].second_triplet # of last used duodon
try:
for triplet_2 in self.host_tuplelist[host_codon + 1]:
duodons.append(Duodon(triplet_1, triplet_2))
except:
duodons.append(Duodon(triplet_1, "NNN"))
return duodons
return_all_matching_duodons
def return_all_matching_duodons(
self,
triplet,
duodons,
frameshift=0
)
View Source
def return_all_matching_duodons(self, triplet, duodons, frameshift=0):
matching_duodons = []
for duodon in duodons:
host_letters = duodon.first_triplet + duodon.second_triplet
# compare 1st letter:
if not compare_letters(host_letters[0 + frameshift], triplet[0]):
continue
if not compare_letters(host_letters[1 + frameshift], triplet[1]):
continue
if not compare_letters(host_letters[2 + frameshift], triplet[2]):
continue
matching_duodons.append(duodon)
return matching_duodons


Cluster file version 1 reference
Estimated reading time: 22 minutesThis topic describes version 1 of the Cluster file format.
Cluster file structure and examples
variable:
domain: "YOUR DOMAIN, e.g. docker.com"
subdomain: "A SUBDOMAIN, e.g. cluster"
region: "THE AWS REGION TO DEPLOY, e.g. us-east-1"
email<EMAIL_ADDRESS>ucp_password:
type: prompt
provider:
acme:
email: ${email}
server_url: https://acme-staging-v02.api.letsencrypt.org/directory
aws:
region: ${region}
cluster:
dtr:
version: docker/dtr:2.6.5
engine:
version: ee-stable-18.09.5
ucp:
username: admin
password: ${ucp_password}
version: docker/ucp:3.1.6
resource:
aws_instance:
managers:
instance_type: t2.xlarge
os: Ubuntu 16.04
quantity: 3
registry:
instance_type: t2.xlarge
os: Ubuntu 16.04
quantity: 3
workers:
instance_type: t2.xlarge
os: Ubuntu 16.04
quantity: 3
aws_lb:
apps:
domain: ${subdomain}.${domain}
instances:
- workers
ports:
- 80:8080
- 443:8443
dtr:
domain: ${subdomain}.${domain}
instances:
- registry
ports:
- 443:443
ucp:
domain: ${subdomain}.${domain}
instances:
- managers
ports:
- 443:443
- 6443:6443
aws_route53_zone:
dns:
domain: ${domain}
subdomain: ${subdomain}
The topics on this reference page are organized alphabetically by top-level keys
to reflect the structure of the Cluster file. Top-level keys that define
a section in the configuration file, such as cluster
, provider
, and resource
,
are listed with the options that support them as sub-topics. This information
maps to the indent structure of the Cluster file.
cluster
Specifies components to install and configure for a cluster.
The following components are available:
subscription
: (Optional) Configuration options for Docker Enterprise Subscriptions.cloudstor
: (Optional) Configuration options for Docker Cloudstor.dtr
: (Optional) Configuration options for Docker Trusted Registry.engine
: (Optional) Configuration options for Docker Engine.ucp
: (Optional) Configuration options for Docker Universal Control Plane.registry
: (Optional) Configuration options for authenticating nodes with a registry to pull Docker images.
subscription
Provide Docker Enterprise subscription information
id
: (Optional) The subscription UUID for this Docker Enterprise installationsub-xxxx
.license
: (Optional) The absolute path to a local Docker Enterprise license file/path/to/docker_subscription.lic
.trial
: (Optional) Specify if this is a trial subscription. Default isfalse
cloudstor
Docker Cloudstor is a Docker Swarm Plugin that provides persistent storage to Docker Swarm Clusters deployed on to AWS or Azure. By default Docker Cloudstor is not installed on Docker Enterprise environments created with Docker Cluster.
cluster:
cloudstor:
version: '1.0'
For more information on Docker Cloudstor see:
The following optional elements can be specified:
version
: (Required) The version of Docker Cloudstor to install. The default isdisabled
. The only released version of Docker Cloudstor at this time is1.0
.use_efs
: (Optional) Specifies whether an Elastic File System should be provisioned. By default Docker Cloudstor on AWS uses Elastic Block Store, therefore this value defaults tofalse
.
dtr
Customizes the installation of Docker Trusted Registry.
cluster:
dtr:
version: "docker/dtr:2.6.5"
install_options:
- "--debug"
- "--enable-pprof"
The following optional elements can be specified:
version
: (Optional) The version of DTR to install. Defaults todocker/dtr:2.6.5
.ca
: (Optional) The path to a root CA public certificate.key
: (Optional) The path to a TLS private key.cert
: (Optional) The path to a public key certificate.install_options
: (Optional) Additional DTR install options.
engine
Customizes the installation of Docker Enterprise Engine.
cluster:
engine:
channel: "stable"
edition: "ee"
version: "19.03"
The following optional elements can be specified:
version
: (Optional) The version of the Docker Engine to install. Defaults to19.03
.edition
: (Optional) The family of Docker Engine to install. Defaults toee
for Enterprise edition.channel
: (Optional) The channel on the repository to pull updated packages. Defaults tostable
.url
: (Optional) Defaults to “https://storebits.docker.com/ee”.storage_driver
: (Optional) The storage driver to use for the storage volume. Default value is dependent on the operating system.- Amazon Linux 2 is
overlay2
. - Centos is
overlay2
. - Oracle Linux is
overlay2
. - RedHat is
overlay2
. - SLES is
btrfs
. - Ubuntu is
overlay2
.
- Amazon Linux 2 is
storage_fstype
: (Optional) File system to use for storage volume. Default value is dependent on the operating system.- Amazon Linux 2 is
xfs
. - Centos is
xfs
. - Oracle Linux is
xfs
. - RedHat is
xfs
. - SLES is
btrfs
. - Ubuntu is
ext4
.
- Amazon Linux 2 is
storage_volume
: (Optional) Docker storage volume path for/var/lib/docker
Default value is provider dependent.- AWS
- non-NVME is
/dev/xvdb
. - NVME disks are one of
/dev/nvme[0-26]n1
.
- non-NVME is
- Azure is
/dev/disk/azure/scsi1/lun0
.
- AWS
daemon
: (Optional) Provides docker daemon options. Defaults to “”.ca
: (dev) Defaults to “”.key
: (dev) Defaults to “”.enable_remote_tcp
: (dev) Enables direct access to docker engine. Defaults tofalse
.
*dev indicates that the functionality is only for development and testing.
kubernetes
Enables provider-specific options for Kubernetes support.
AWS Kubernetes options
cloud_provider
: (Optional)Enable cloud provider support for Kubernetes. Defaults tofalse
.ebs_persistent_volumes
: (Optional) Enable persistent volume support with EBS volumes. Defaults tofalse
.efs_persistent_volumes
: (Optional) Enable persistent volume support with EFS. Defaults tofalse
.load_balancer
: (Optional) Enable Kubernetes pods to instantiate a load-balancer. Defaults tofalse
.nfs_storage
: (Optional) Install additional packages on node for NFS support. Defaults tofalse
.lifecycle
: (Optional) Defaults toowned
.
registry
Customizes the registry from which the installation should pull images. By default, Docker Hub and credentials to access Docker Hub are used.
cluster:
registry:
password: ${base64decode("TVJYeTNDQWpTSk5HTW1ZRzJQcE1kM0tVRlQ=")}
url: https://index.docker.io/v1/
username: user
The following optional elements can be specified:
username
: The username for logging in to the registry on each node. Default value is the current docker user.url
: The registry to use for pulling Docker images. Defaults to “https://index.docker.io/v1/”.password
: The password for logging in to the registry on each node. Default value is the current docker user’s password base64 encoded and wrapped in a call to base64decode.
ucp
version
: Specifies the version of UCP to install. Defaults todocker/ucp:3.1.6
.username
: Specifies the username of the first user to create in UCP. Defaults toadmin
.password
: Specifies the password of the first user to create in UCP. Defaults todockerdocker
.ca
: Specifies a path to a root CA public certificate.key
: Specifies a path to a TLS private key.cert
: Specifies a path to a public key certificate.install_options
: Lists additional UCP install options
Additional UCP configuration options
Docker Cluster also accepts all UCP configuration options and creates the initial UCP config on installation. The following list provides supported options:
anonymize_tracking
: Anonymizes analytic data. Specify ‘true’ to hide the license ID. Defaults to ‘false’.audit_level
: Specifies the audit logging level. Leave empty for disabling audit logs (default). Other valid values are ‘metadata’ and ‘request’.auto_refresh
: Specify ‘true’ to enable attempted automatic license renewal when the license nears expiration. If disabled, you must manually upload renewed license after expiration. Defaults to ‘true’.azure_ip_count
: Sets the IP count for azure allocator to allocate IPs per Azure virtual machine.backend
: Specifie the name of the authorization backend to use, either ‘managed’ or ‘ldap’. Defaults to ‘managed’.calico_mtu
: Specifies the MTU (maximum transmission unit) size for the Calico plugin. Defaults to ‘1480’.cloud_provider
: Specifies the cloud provider for the kubernetes cluster.cluster_label
: Specifies a label to be included with analytics/.cni_installer_url
: Specifies the URL of a Kubernetes YAML file to be used for installing a CNI plugin. Only applies during initial installation. If empty, the default CNI plugin is used.controller_port
: Configures the port that the ‘ucp-controller’ listens to. Defaults to ‘443’.custom_header_name
: Specifies the name of the custom header with ‘name’ = ‘X-Custom-Header-Name’.custom_header_value
: Specifies the value of the custom header with ‘value’ = ‘Custom Header Value’.default_new_user_role
: Specifies the role that new users get for their private resource sets. Values are ‘admin’, ‘viewonly’, ‘scheduler’, ‘restrictedcontrol’, or ‘fullcontrol’. Defaults to ‘restrictedcontrol’.default_node_orchestrator
: Specifies the type of orchestrator to use for new nodes that are joined to the cluster. Can be ‘swarm’ or ‘kubernetes’. Defaults to ‘swarm’.disable_tracking
: Specify ‘true’ to disable analytics of API call information. Defaults to ‘false’.disable_usageinfo
: Specify ‘true’ to disable analytics of usage information. Defaults to ‘false’.dns
: Specifies a CSV list of IP addresses to add as nameservers.dns_opt
: Specifies a CSV list of options used by DNS resolvers.dns_search
: Specifies a CSV list of domain names to search when a bare unqualified hostname is used inside of a container.enable_admin_ucp_scheduling
: Specify ‘true’ to allow admins to schedule on containers on manager nodes. Defaults to ‘false’.external_service_lb
: Specifies an optional external load balancer for default links to services with exposed ports in the web interface.host_address
: Specifies the address for connecting to the DTR instance tied to this UCP cluster.log_host
: Specifies a remote syslog server to send UCP controller logs to. If omitted, controller logs are sent through the default docker daemon logging driver from the ‘ucp-controller’ container.idpMetadataURL
: Specifies the Identity Provider Metadata URL.image_repository
: Specifies the repository to use for UCP images.install_args
: Specifies additional arguments to pass to the UCP installer.ipip_mtu
: Specifies the IPIP MTU size for the calico IPIP tunnel interface.kube_apiserver_port
: Configures the port to which the Kubernetes API server listens.kv_snapshot_count
: Sets the key-value store snapshot count setting. Defaults to ‘20000’.kv_timeout
: Sets the key-value store timeout setting, in milliseconds. Defaults to ‘5000’.lifetime_minutes
: Specifies the initial session lifetime, in minutes. Defaults to4320
, which is 72 hours.local_volume_collection_mapping
: Stores data about collections for volumes in UCP’s local KV store instead of on the volume labels. This is used for enforcing access control on volumes.log_level
: Specifies the logging level for UCP components. Values are syslog priority levels (https://linux.die.net/man/5/syslog.conf): ‘debug’, ‘info’, ‘notice’, ‘warning’, ‘err’, ‘crit’, ‘alert’, and ‘emerg’.managedPasswordDisabled
: Indicates if managed password is disabled. Defaults to false.managedPasswordFallbackUser
: The fallback user when the managed password authentication is disabled. Defaults to “”.manager_kube_reserved_resources
: Specifies reserve resources for Docker UCP and Kubernetes components that are running on manager nodes.metrics_disk_usage_interval
: Specifies the interval for how frequently storage metrics are gathered. This operation can impact performance when large volumes are present.metrics_retention_time
: Adjusts the metrics retention time.metrics_scrape_interval
: Specifies the interval for how frequently managers gather metrics from nodes in the cluster.nodeport_range
: Specifies the port range that for Kubernetes services of type NodePort can be exposed in. Defaults to ‘32768-35535’.per_user_limit
: Specifies the maximum number of sessions that a user can have active simultaneously. If the creation of a new session would put a user over this limit, the least recently used session is deleted. A value of zero disables limiting the number of sessions that users can have. Defaults to5
.pod_cidr
: Specifies the subnet pool from which the IP for the Pod should be allocated from the CNI ipam plugin.profiling_enabled
: Specify ‘true’ to enable specialized debugging endpoints for profiling UCP performance. Defaults to ‘false’.log_protocol
: Specifies the protocol to use for remote logging. Values are ‘tcp’ and ‘udp’. Defaults to ‘tcp’.renewal_threshold_minutes
: Specifies the length of time, in minutes, before the expiration of a session. When used, a session is extended by the current configured lifetime from that point in time. A zero value disables session extension. Defaults to1440
, which is 24 hours.require_content_trust
: Specify ‘true’ to require images be signed by content trust. Defaults to ‘false’.require_signature_from
: Specifies a csv list of users or teams required to sign images.rethinkdb_cache_size
: Sets the size of the cache used by UCP’s RethinkDB servers. TDefaults to 1GB, but leaving this field empty or specifyingauto
instructs RethinkDB to determine a cache size automatically.rootCerts
: Defaults to empty.samlEnabled
: Indicates if saml is used.samlLoginText
: Specifies the customized SAML login button text.service_id
: Specifies the DTR instance’s OpenID Connect Client ID, as registered with the Docker authentication provider.spHost
: Specifies the Service Provider Host.storage_driver
: Specifies the UCP storage driver to install.support_dump_include_audit_logs
: When set totrue
, support dumps include audit logs in the logs of the ‘ucp-controller’ container of each manager node. Defaults to ‘false’.swarm_port
: Configures the port that the ‘ucp-swarm-manager’ listens to. Defaults to ‘2376’.swarm_strategy
: Configures placement strategy for container scheduling. This doesn’t affect swarm-mode services. Values are ‘spread’, ‘binpack’, and ‘random’.tlsSkipVerify
: Specifies TLS Skip verify for IdP Metadata.unmanaged_cni
: Defaults to ‘false’.worker_kube_reserved_resources
: Reserves resources for Docker UCP and Kubernetes components that are running on worker nodes.custom_kube_api_server_flags
: Specifies the configuration options for the Kubernetes API server. (dev)custom_kube_controller_manager_flags
: Specifies the configuration options for the Kubernetes controller manager. (dev)custom_kube_scheduler_flags
: Specifies the configuration options for the Kubernetes scheduler. (dev)custom_kubelet_flags
: Specifies the configuration options for Kubelets. (dev)
*dev indicates that the functionality is only for development and testing. Arbitrary Kubernetes configuration parameters are not tested and supported under the Docker Enterprise Software Support Agreement.
vpc
If you are deploying on to AWS, by default Docker Cluster will create a new AWS VPC (Virtual Private Cloud) for the Docker Enterprise resources. To specify an existing VPC, a user can specify a VPC ID in the Cluster File.
cluster:
vpc:
id: vpc-existing-vpc-id
Docker Cluster assumes the VPC CIDR is <IP_ADDRESS>/16
, so will therefore
attempt to create AWS subnets from this range. Docker Cluster can not utilise
existing AWS subnets. To instruct Docker Cluster to provision subnets for an
alternative CIDR you can pass a new CIDR into the Cluster File.
cluster:
vpc:
id: vpc-existing-vpc-id
cidr: "<IP_ADDRESS>/16"
The following elements can be specified:
id
- (Required) The existing AWS VPC IDvpc-xxx
cidr
- If the VPC’s CIDR is not the default<IP_ADDRESS>/16
an alternative CIDR can be specified here.
provider
Defines where the cluster’s resources are provisioned, as well as provider-specific configuration such as tags.
provider:
acme:
email: ${email}
server_url: https://acme-staging-v02.api.letsencrypt.org/directory
aws:
region: ${region}
acme
The Automated Certificate Management Environment (ACME) is an evolving standard for the automation of a domain-validated certificate authority. Docker Cluster uses the ACME provider to create SSL certificates that are signed by Let’s Encrypt.
The ACME provider Configuration for the ACME provider supports arguments that closely align with the Terraform ACME provider:
The following elements can be specified:
email
: (Required) The email to associate the certificates with.server_url
: (Optional) The URL to the ACME endpoint’s directory. Default is “https://acme-v02.api.letsencrypt.org/directory”
aws
Configuration for the AWS provider supports arguments that closely align with the Terraform AWS provider.
aws:
region: "us-east-1"
tags:
Owner: "Infra"
Environment: "Test"
The following elements can be specified:
region
- (Required) This is the AWS region. It can be sourced from theAWS_DEFAULT_REGION
environment variables, or via a shared credentials file ifprofile
is specified.tags
- (Optional) Additional name value pairs to assign to every resource (which supports tagging) in the cluster.access_key
- (Required) This is the AWS access key. It can be sourced from theAWS_ACCESS_KEY_ID
environment variable, or via a shared credentials file ifprofile
is specified.secret_key
- (Required) This is the AWS secret key. It can be sourced from theAWS_SECRET_ACCESS_KEY
environment variable, or via a shared credentials file ifprofile
is specified.profile
- (Optional) This is the AWS profile name as set in the shared credentials file.assume_role
- (Optional) Anassume_role
block (documented below). Only oneassume_role
block can be in the configuration.endpoints
- (Optional) Configuration block for customizing service endpoints. See the Custom Service Endpoints Guide for more information about connecting to alternate AWS endpoints or AWS compatible solutions.shared_credentials_file
= (Optional) This is the path to the shared credentials file. If this is not set and a profile is specified,~/.aws/credentials
is used.token
- (Optional) Session token for validating temporary credentials. Typically provided after successful identity federation or Multi-Factor Authentication (MFA) login. With MFA login, this is the session token provided afterwards, not the 6 digit MFA code used to get temporary credentials. It can also be sourced from theAWS_SESSION_TOKEN
environment variable.max_retries
- (Optional) This is the maximum number of times an API call is retried, in the case where requests are being throttled or experiencing transient failures. The delay between the subsequent API calls increases exponentially.allowed_account_ids
- (Optional) List of allowed, white listed, AWS account IDs to prevent you from mistakenly using an incorrect one (and potentially end up destroying a live environment). Conflicts withforbidden_account_ids
.forbidden_account_ids
- (Optional) List of forbidden, blacklisted, AWS account IDs to prevent you mistakenly using a wrong one (and potentially end up destroying a live environment). Conflicts withallowed_account_ids
.insecure
- (Optional) Explicitly allows the provider to perform “insecure” SSL requests. If omitted, defaults tofalse
.skip_credentials_validation
- (Optional) Skips the credentials validation via the STS API. Useful for AWS API implementations that do not have STS available or implemented.skip_get_ec2_platforms
- (Optional) Skips getting the supported EC2 platforms. Used by users that don’t haveec2:DescribeAccountAttributes
permissions.skip_region_validation
- (Optional) Skips validation of provided region name. Useful for AWS-like implementations that use their own region names or to bypass the validation for regions that aren’t publicly available yet.
resource
Resources to provision for a cluster. Resources are organized as shown in the following example:
resource:
type:
name:
parameters
For a given type
, there may be more one or more named resources to provision.
For a given name
, a resource may have one or more parameters.
aws_instance
resource:
aws_instance:
workers:
instance_type: t2.xlarge
price: 0.25
os: Ubuntu 16.04
quantity
: (Required) The number of instances to create.os
: An alias that is expanded bydocker cluster
to the AMI owner and AMI name to install. The following aliases are supported bydocker cluster
:CentOS 7
RHEL 7.1
RHEL 7.2
RHEL 7.3
RHEL 7.4
RHEL 7.5
RHEL 7.6
Oracle Linux 7.3
Oracle Linux 7.4
Oracle Linux 7.5
SLES 12.2
SLES 12.3
SLES 15
Ubuntu 14.04
Ubuntu 16.04
Ubuntu 18.04
Windows Server 2016
Windows Server 1709
Windows Server 1803
Windows Server 2019
Note: Make sure the OS you select is compatible with the product you’re installing. Docker Cluster validates the support during installation.
instance_type
: Specifies the AWS instance type to provision.key_name
: By default, Docker Cluster creates an AWS EC2 Key Pair and registers it with AWS for the cluster. To use an existing AWS EC2 Key Pair, set this value to the name of the AWS EC2 Key Pair.ssh_private_key
: By default, Docker Cluster creates an AWS EC2 Key Pair and registers it with AWS for the cluster. To use an existing AWS EC2 Key Pair, set this value to the path of the private SSH key.username
: Specifies the username for the node with Administrative privileges. By default, theos
option sets this to the well-known username for the AMIs (which can change by distribution):- Amazon Linux 2 is
ec2-user
. - Centos is
centos
. - Oracle Linux is
ec2-user
. - RedHat is
ec2-user
. - SLES is
ec2-user
. - Ubuntu is
ubuntu
. - Windows is
Administrator
.
- Amazon Linux 2 is
password
: This value is only used by Windows nodes. By default, Windows nodes have a random password generated.ami
: Specifies a custom AMI, or one that’s not currently available as an OS. Specify either the id or the owner/name to query for the latest.id
: Specifies the ID of the AMI. For example,ami-0510c89f1a2691cf2
.owner
: Specifies the AWS account ID of the image owner. For example,099720109477
.name
: Specifies the name of the AMI that was provided during image creation. For example,ubuntu/images/hvm-ssd/ubuntu-xenial-16.04-amd64-server-*
.platform
: Specifywindows
for Windows instances.
tags
: (Optional) Specifies additional name value pairs to assign to every instance.swarm_labels
: (Optional) Specifies additional key value pairs that represent swarm labels to apply to every node.
aws_spot_instance_request
Provisions a spot instance request in AWS to dramatically reduce the cost of instances. Spot instance
availability is not guaranteed. Therefore, it is recommended to use aws_spot_instance_request
for
additional worker nodes and not for mission-critical nodes like managers and registry.
resource:
aws_spot_instance_request:
workers:
instance_type: t2.xlarge
price: 0.25
os: Ubuntu 16.04
quantity: 3
Supports the same set of parameters as aws_instance, with the addition of an optional price to limit the max bid for a spot instance.
price
: (Optional) Specifies a maximum price to bid on the spot instance.
aws_lb
Provisions an AWS Load Balancer.
resource:
aws_lb:
ucp:
domain: "example.com"
instances:
- managers
ports:
- 443:443
- 6443:6443
The following options are supported:
instances
: (Required) Specifies a list ofaws_instance
andaws_spot_instance_request
names to attach to the load balancer.ports
: (Required) Specifies a list oflistening port[/protocol]:target port[/protocol]
mappings to define how the load balancer should route traffic. By default, the protocol istcp
.domain
: Specifies the domain in which to create DNS records for this load balancer. The record is named the same as this resource, appended by the domain. For example, if the resource isucp
and the domain isexample.com
, theA
record isucp.example.com
.internal
: (Optional) Defaults tofalse
.type
: (Optional) Defaults tonetwork
.enable_cross_zone_load_balancing
: (Optional) Defaults tofalse
.
aws_route53_zone
Creates a subdomain in an AWS route53 zone. The following example creates a public zone for testing.example.com
:
resource:
aws_route53_zone:
dns:
domain: example.com
subdomain: testing
The following elements are required:
domain
: (Required) Specifies the name of the hosted zone.subdomain
: (Required) Specifies the subdomain to create in thedomain
hosted zone.
variable
Docker cluster supports basic parameterization. The variable section defines a make of keys and values. A key can have a sub-key named type
, which changes the behavior of the variable.
variable:
region: "us-east-1"
password:
prompt: true
instance_type:
env: AWS_INSTANCE_TYPE
Variables are referenced in the cluster definition as ${variable_name}
. For
example, ${region}
is substituted as us-east-2
through the cluster
definition.
In addition to providing a literal value for variables, you can specify values by:
prompt: true
- Request the value from the user and do not echo characters as the value is entered.env
: Obtain the value from an environment variable


How Would You Like Your Groceries Delivered?
Select a Recipe:
Avocado Quinoa
Baby Back Ribs
Cookies
Manicotti
Tilapia
Turkey
Veggie Pasta
Add to Cart!
Empty Cart
Refresh Page
Inspiration from:
Created by: Leslie Tanner
Weight in Cart:
Enter delivery address.
Nearest Site:
Latitude:
Longitude:
To actually succeed at such distance, this would take:
It could grip it by the husk!
Credit:
Drone by Blaise Sewell from the Noun Project
Some Icons made by
Freepik
from
www.flaticon.com
is licensed by
CC 3.0 BY


Take advantages of sales skills & experience and understanding of market to become a professional Sales Staff and bring a lot value to Customers. From that, I will contribute to development of TOPCV Company.
Major: Applied Informatics
GPA: 4.0/4.0
Sales Staff
Main responsibilities:
- Write and upload product advertising post via Facebook, Forum...
- Introduce, consult products and answer customers' queries via phone and email.
- Assist to control goods in and out
- Attend Sales Skill Course in the Company
Part-time Sales Staff
- Sell goods for Foreigners and Vietnamese at the Shop
- Advertise products on media publications such as: banner, posters,leaflets...
- Make reports of sales every day
Member of US Ambassador
Member of US Ambassador
- Share how to hunt scholarships and US student's life experiences to all students who have received offers from US universities
Office
Logical thinking and creative
English


| Total net profit | 6.35 | Gross profit | 12.21 | Gross loss | -5.86 |
| Profit factor | 2.08 | Expected payoff | 0.49 | ||
| Absolute drawdown | 3.73 | Maximal drawdown (%) | 3.69 (38.56%) | ||
| Total trades | 13 | Profit trades (% of total) | 10 (76.92%) | Loss trades (% of total) | 3 (23.08%) |
| Long positions (won %) | 5 (80.0%) | Short positions (won %) | 8 (75.0%) | ||
| Largest | profit trade | 3.73 | loss trade | -3.35 | |
| Average | profit trade | 1.22 | loss trade | -1.95 | |
| Minimum | profit trade | 0.21 | loss trade | -0.05 | |
| Maximum | take profit in pips | 36.6 | stop loss in pips | -36.9 | |
| Average | take profit in pips | 9.8 | stop loss in pips | -26.5 | |
| Minimum | take profit in pips | -0.6 | stop loss in pips | -11.6 | |
| Maximum | Reward-Risk | 1.7 | Duration in minutes | 8128 | |
| Average | Reward-Risk | 0.5 | Duration in minutes | 1023.8 | |
| Minimum | Reward-Risk | 0.0 | Duration in minutes | 9 | |
| Maximum | consecutive wins (profit in money) | 6.0 (9.57) | consecutive losses (loss in money) | 2.0 (-3.4) | |
| Average | consecutive wins | 4.0 | consecutive losses | 1.0 |
| Total net profit | 3.98 | Gross profit | 4.03 | Gross loss | -0.05 |
| Profit factor | 80.6 | Expected payoff | 0.8 | ||
| Absolute drawdown | 0.92 | Maximal drawdown (%) | 0.05 (1.57%) | ||
| Total trades | 5 | Profit trades (% of total) | 4 (80.0%) | Loss trades (% of total) | 1 (20.0%) |
| Largest | profit trade | 2.26 | loss trade | -0.05 | |
| Average | profit trade | 1.01 | loss trade | -0.05 | |
| Minimum | profit trade | 0.21 | loss trade | -0.05 | |
| Maximum | take profit in pips | 21.8 | stop loss in pips | -36.9 | |
| Average | take profit in pips | 7.6 | stop loss in pips | -29.0 | |
| Minimum | take profit in pips | -0.6 | stop loss in pips | -13.0 | |
| Maximum | Reward-Risk | 1.7 | Duration in minutes | 2141.0 | |
| Average | Reward-Risk | 0.4 | Duration in minutes | 466.8 | |
| Minimum | Reward-Risk | 0.0 | Duration in minutes | 13.0 | |
| Maximum | consecutive wins (profit in money) | 2.0 (3.18) | consecutive losses (loss in money) | 1.0 (-0.05) | |
| Average | consecutive wins | 2.0 | consecutive losses | 1.0 |
| Total net profit | 2.37 | Gross profit | 8.18 | Gross loss | -5.81 |
| Profit factor | 1.41 | Expected payoff | 0.3 | ||
| Absolute drawdown | 1.9 | Maximal drawdown (%) | 4.49 (70.27%) | ||
| Total trades | 8 | Profit trades (% of total) | 6 (75.0%) | Loss trades (% of total) | 2 (25.0%) |
| Largest | profit trade | 3.73 | loss trade | -3.35 | |
| Average | profit trade | 1.36 | loss trade | -2.91 | |
| Minimum | profit trade | 0.47 | loss trade | -2.46 | |
| Maximum | take profit in pips | 36.6 | stop loss in pips | -31.7 | |
| Average | take profit in pips | 11.2 | stop loss in pips | -25.0 | |
| Minimum | take profit in pips | 4.2 | stop loss in pips | -11.6 | |
| Maximum | Reward-Risk | 1.3 | Duration in minutes | 8128.0 | |
| Average | Reward-Risk | 0.5 | Duration in minutes | 1371.9 | |
| Minimum | Reward-Risk | Duration in minutes | 9.0 | ||
| Maximum | consecutive wins (profit in money) | 4.0 (6.39) | consecutive losses (loss in money) | 1.0 (-3.35) | |
| Average | consecutive wins | 2.0 | consecutive losses | 1.0 |


My name is Ibrohim I am a programmer, and my interest in this profession began from early childhood ...
When I first went to school, then they bought me a small push-button phone and there was a game in this
phone. I played it all the time and I had one question, "How was this game created?" Years passed and when I
bought a touchscreen phone, I started making games in it. And in order to learn how to do this, I went to very
beautiful sites, then I developed an interest in sites, but since I did not have a computer at that time, I
could not create sites. When I grew up, we got a computer and I started learning. I studied at the training
center (I am studying even now). In May 2021, I finished the frontend course and moved to the backend. Now,
namely August 2021, I continue to study in the backend course and soon
I will finish it ... Well, that's my
whole story of becoming a programmer


Shadow DOM
- Repository
- github.com/polymer/ShadowDOM
- W3C Specification
- dvcs.w3.org/hg/webcomponents/raw-file/tip/spec/shadow/index.html
Shadow DOM is designed to provide encapsulation by hiding DOM subtrees under shadow roots. It provides a method of establishing and maintaining functional boundaries between DOM trees and how these trees interact with each other within a document, thus enabling better functional encapsulation within the DOM.
Table of contents
Learn the tech
Basic usage
var el = document.createElement('div');
var shadow = el.createShadowRoot();
shadow.innerHTML = '<content select="h1"></content>';
document.body.appendChild(el);
Shadow DOM subtrees
Shadow DOM allows a single node to express three subtrees: light DOM, shadow DOM, and composed DOM.
Together, the light DOM and shadow DOM are referred to as the logical DOM. This is the DOM that the developer interacts with. The composed DOM is what the browser sees and uses to render the pixels on the screen.
Light DOM
The user of your custom element supplies the light DOM:
<my-custom-element>
<q>Hello World</q>
</my-custom-element>
The light DOM of <my-custom-element>
is visible to the end-user of the
element as a normal subtree. They can access .childNodes
, .children
, .innerHTML
, or any other property or method that gives information about a node’s subtree.
Shadow DOM
<my-custom-element>
may define shadow DOM by attaching a shadow root to
itself.
#document-fragment

People say: <content></content>
sometimes
Shadow DOM is internal to the element and hidden from the end-user.
Its nodes are not children of <my-custom-element>
.
Note: Shadow roots are represented as a #document-fragment
in the DevTools.
Composed (rendered) DOM
The composed DOM is what the browser actually renders. For rendering, the light DOM is distributed into the shadow DOM to produce the composed DOM. The final output looks something like this:
<my-custom-element>
People say: <q>Hello World</q>
sometimes
</my-custom-element>
Nodes in light DOM or shadow DOM express parent and sibling relationships that match their respective tree structures; the relationships that exist in the composed tree are not expressed anywhere in DOM. So, while the
in the final composed tree is a child of <my-custom-element>
and the parent of <q>
, it is actually a child of the shadow root and <q>
is a child of <my-custom-element>
. The two nodes are unrelated but
Shadow DOM renders them as if they are. In this way, the user can manipulate light DOM or shadow DOM directly as regular DOM subtrees, and let the system take care of keeping the render tree synchronized.
Polyfill details
A polyfill to provide Shadow DOM functionality in browsers that don’t support it natively. This section explains how a proper (native) implementation differs from our polyfill implementation.
Wrappers
The polyfill is implemented using wrappers. A wrapper wraps the native DOM node in a wrapper node. The wrapper node looks and behaves identical to the native node (minus bugs and known limitations). For example:
var div = document.createElement('div');
div.innerHTML = 'Hello world';
assert(div.firstChild instanceof HTMLElement);
But div
is actually a wrapper of the element that the browser normally gives you. This wrapper just happen to have the same interface as the browser provided element.
It has an innerHTML
setter that works just like the native innerHTML
but it instead of working on the composed tree it works on the local DOM. When you change the logical DOM tree like this it might cause the composed tree to need to be re-rendered. This does not happen immediately, but it is scheduled to happen later as needed.
The wrapper node also have a firstChild
getter which once again works on the logical DOM.
instanceof
still works because we have replaced the global HTMLElement
constructor with our custom one.
More Logical DOM
The wrappers.Node
object keeps track of the logical (light as well as shadow, but not composed) DOM. Internally it has has the 5 fundamental Node pointers, parentNode
, firstChild
, lastChild
, nextSibling
and previousSibling
. When the DOM tree is manipulated these pointers are updated to always represent the logical tree. When the shadow DOM renderer needs to render the visual tree, these internal pointers are updated as needed.
Wrap all the objects!
The intent is to wrap all the DOM objects that interact with the DOM tree. For this polyfill to be completely transparent we need to wrap a lot of APIs. Any method, accessor or constructor that takes or returns a Node or an object that indirectly touches a node needs to be wrapped. As you can imagine there are a lot of these. At the moment we have done the most common ones but there are sure to be missing ones as soon as you try to use this with your code.
wrap
and unwrap
There are bound to be cases where we haven’t done the wrapping for you. In those cases you can use wrap
to create a wrapper of a native object, or unwrap
to get the underlying native object from a wrapper. These two functions are available on the ShadowDOMPolyfill
object.
Event Retargetting
An important aspect of the shadow DOM is that events are retargetted to never expose the shadow DOM to the light DOM. For example.
var div = document.createElement('div');
div.innerHTML = 'Click me';
var shadow = div.createShadowRoot();
shadow.innerHTML = '<content></content>';
If the user clicks on the div
the real target
of the click event is the
element. But that element is not visible in the light DOM so the target is therefore retargetted to the div
element itself. However, if there is an event listener on the <content>
,
or the shadow root, the target should be visible to the event listener.
Similar issues occur with relatedTarget
in mouseover
and mouseout
events.
To support this kind of behavior the event dispatching in the browser has to be reimplemented by the polyfill.
Known limitations
- CSS encapsulation is limited.
Object.prototype.toString
does not return the same string as for native objects.- No live
NodeList
s. All node lists are snapshotted upon read. document
,window
,document.body
,document.head
and others are non configurable and cannot be overridden. We are trying to make these work as seamlessly as possible but there will doubtlessly be cases where there will be problems; for those cases you can usewrap
andunwrap
to get unblocked.- Cross window/frame access is not implemented.
- CSS
:host()
rules can only have (at most) 1-level of nested parentheses in its argument selector. For example,:host(.zot)
and:host(.zot:not(.bar))
both work, but:host(.zot:not(.bar:nth-child(2)))
does not.


Description
Experimental HTML5 panorama viewer using the new HTLM5 canvas element.
This script displays equirectangular (360x180) panoramas. So just one
image is necessary to display a complete 360x180 panorama.
Purpose
I mainly was curious how fast equirectangular panorama image can be
displayed with a HTML5 canvas. So the script isn't cleaned up very well,
but it gave me at least an idea that it is possible. On my an Intel Core
i7 CPU I get more than 20 frames per second. That is of course not very
fast but usable. And the best of all it doesn't require any Plug-Ins :)
Navigation
- Left/Right Mouse drag: Changes camera heading.
- Up/Sown Mouse drag: Changes camera pitch.
- Scroll wheel: Changes camera field of view.
- I-Key: Displays Info panel with canvas size, image size and FPS.
Requirements
I've tested this HTML5 panorama script with the latest versions of Safari,
Firefox and Chrome on Mac OS X. But it should also run on other platforms
supporting HTML5.
License
The html5pano.js script is released under the Simplified BSD License.
Please see comments within the script.
Dowload
Please use the following link to download the script including a sample
panorama image.
http://www.cheetah3d.com/download/HTML5pano/HTML5pano.zip
17.Aug.2010, Martin Wengenmayer


Logout
Design your taco!


Picture a completed page and desired functionality, and work backwards.
MS Expression Web 4
Good for HTML and CSS, no auto-formatting for JS (no auto-indent or paren matching)
Liveweave.com
Real-time collaborative HTML, CSS, and JS editing
Notable frameworks and libraries
jQuery
Bootstrap
Deploy on Github Pages


But I'm not going to tell which one to like. Pick the one that makes sense for your project. And what makes to sense to you.
obj.set('key', 'val')
instead of obj.key = val
like in Angular.There's tons of great things about these frameworks that we didn't talk about. Core features even.


Hello people,
i am having problems connecting the emonbase to my database. This are my specs:
i have a emonTx assembled and working. ( i know this because i also have a emonglcd and this gives the amount of Watt used on the power group)
I have a router that works with dhcp. And this are the things i have programmed in my emonbase.
* I have changed the mac adress ones (no changes)
* byte Ethernet::buffer[700];
* static uint32_t timer;
* char website[] PROGMEM = "http://mydyndns website/emoncms"; (emoncms is the directory on my QNAPnas where emoncms is in.)
* ether.browseUrl(PSTR("http://***.dyndns.org/emoncms/api/post?apikey=myAPIwrite key&json="),str.buf, website, my_callback);
and in the Tab DHCP_DNS is did this:
Re: cannot connect to database, what am i missing..
Hello Iwan
Sorry that this has been giving you so much trouble, I can imagine its really frustrating.
When you type in "http://***.dyndns.org/emoncms/api/post?apikey=myAPIwrite key&json={power:100} directly into your browser does the input: power register? Do you see it in the input list?
The line:
char website[] PROGMEM = "http://mydyndns website/emoncms";
needs to be of the format
char website[] PROGMEM = "mydyndnswebsite.com";
No http and no folder information.
ether.browseUrl(PSTR("http://***.dyndns.org/emoncms/api/post?apikey=myAPIwrite key&json=")
needs to be:
ether.browseUrl(PSTR("/emoncms/api/post?apikey=myAPIwrite key&json=")
Let me know what gets printed to the serial window on the nanodeRF
Re: cannot connect to database, what am i missing..
thanks for your response.....
i have tryed to correct the 2 lines AND i pasted the link incl my API key etc directly in my browser, but it only says...OK in my emoncms screen.
The red light on my emonbase is still shining.....
what can i do????i really do not know what i need to do now. I thout this would be a piece of cake....
*edit* i can see the {100} in my input screen.
Re: cannot connect to database, what am i missing..
Ok I have an idea, could you email me or PM me with yourdyndns website and I can try to send data to it from a nanode here to try and narrow things down a bit? trystan.lea at openenergymonitor.org
Re: cannot connect to database, what am i missing..
sent you an email with the data.
Iwan


with
Balanced:
Each $\mathbf{J}_i$ is balanced.
Unbalanced:
Each $\mathbf{J}_i$ is unbalanced.
Calculate $\left<\mathrm{ln}V_\mathrm{G}\right>$ for given $P$ and $\kappa_\mathrm{in}$ or $\kappa_\mathrm{out}$.


--- layout: post title: Finding Digital Marketing Software date: 2014-09-28 01:27:58.000000000 +01:00 categories: - Digital Marketing tags: [] status: publish type: post published: true meta: _edit_last: '1' _wpas_done_all: '1' _thumbnail_id: '54' _wpas_skip_8772378: '1' _wpas_skip_8772856: '1' _wpt_view_count: '26' author: login<EMAIL_ADDRESS>email<EMAIL_ADDRESS>display_name: Evan first_name: '' last_name: '' excerpt: !ruby/object:Hpricot::Doc options: {} ---
All software and tools should be simple, straightforward, and easy to learn.
Here are my recommendations:
Analytics
Google Analytics can handle a multitude of campaigns and even project future sales with goal conversion. You can track page views, demographics, user flow, browsers, location, and much more.
Quantcast is another option that many companies use. Unfortunately, the data is publicly displayed. However, the demographics are very in-depth.
Social Media Management
Buffer is best suited for managers who aren't interested in special features, but want to see simple and comprehensive analytics. I prefer Buffer because it does not
Hootsuite is best suited for active social media managers who want to have many features. I'd use Hootsuite if I needed special reports. RSS Feeds are included with Hootsuite, but I wouldn't recommend using this all-in-one approach.
RSS Feeds:
Digg Reader is simple and easy to use. Plus, they have a mobile app which allows you to copy links and share to social media.
Link Shortener:
Bitly is by far the best link shortener and I'd try to get a domain specific link shortener. E.g: The Better Business Bureau uses go.bbb.org.
Social Media Monitoring Applications
Mention is one of the priciest, but it's darn good at finding consumers who are commenting on your product or service.
Google Alerts is a free alternative to Mention. It's not the most advanced out there. There are numerous sites than can do current keyword searches for content, just google social media monitoring.
Design and Editing
For Print: Adobe InDesign
For Photo Editing: Adobe Photoshop
For Video Editing: Final Cut Pro is my personal favorite. It's simple and easy to use. The keyframing is a lot easier than Adobe Premiere and it's layout is easy to grasp. The video playback is not as good as Premiere, but I prefer editing in final cut because the timeline is a lot easier to edit. However, I recommend buying the entire Adobe suite and sticking with Adobe Premiere if your business wants to save money.
For Audio: Audition or Soundtrack are excellent options for reducing extra noise etc.
For Wireframe Design: Omnigraffle is the simplest design program out there. What takes an hour in Illustrator, can take a couple of minutes in Omnigraffle. Making arrows is intuitive and the workflow is straightforward.
This is only a short list of the many applications I use on a daily basis. I'll be adding more if any come to mind. If you have any suggestions leave a comment below.
REVISED: Sept 27, 2014
NOTE: This list will be continuously updated and is not considered complete.


Popular posts about deploying Rails apps
How to quickly provision a VPS for Rails using Chef
Deploying with Capistrano 3
Tailing log files with Capistrano 3
Using Vagrant to test Chef Cookbooks


|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.hp.hpl.jena.sparql.engine.optimizer.probability.impl.IndexModelAccess
public class IndexModelAccess
The class is a wrapper around the Jena model used for the specialized index. It implements a number of methods to deal with the specific RDF graph, e.g. load the Jena RDF model into Java data structures or create a Jena RDF model given the Java data structures representing the index.
| Constructor Summary | |
|---|---|
IndexModelAccess()
|
| Method Summary | |
|---|---|
com.hp.hpl.jena.rdf.model.Model |
create(ProbabilityIndex index)
The method creates the Jena model for the specialized index given the probabilistic index as a representation of the statistics used during runtime. |
java.util.Set |
getExProperty()
Return the indexed set of excluded properties |
java.util.Map |
getHistograms()
Return the histograms for the properties, a Map |
int |
getLevel()
Get the level of this index. |
long |
getOOSize()
Return the object-object size as the result set size of the pattern ? |
long |
getOSSize()
Return the object-subject size as the result set size of the pattern ? |
java.util.Map |
getPatterns()
Return the statistics for the indexed joined triple patterns, a Map |
java.util.Map |
getProperties()
Return the statistics for the properties, a Map |
long |
getResources()
Return the number of resources of the indexed ontology. |
long |
getSize()
Return the size of the indexed ontology. |
long |
getSOSize()
Return the subject-object size as the result set size of the pattern ? |
long |
getSSSize()
Return the subject-subject size as the result set size of the pattern ? |
void |
load(com.hp.hpl.jena.rdf.model.Model model)
The method loads a Jena model representing the specialized index into Java data structures for runtime efficient access. |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public IndexModelAccess()
| Method Detail |
|---|
public void load(com.hp.hpl.jena.rdf.model.Model model)
model
- public com.hp.hpl.jena.rdf.model.Model create(ProbabilityIndex index)
index
-
public int getLevel()
public long getSize()
public long getResources()
public long getSSSize()
public long getSOSize()
public long getOSSize()
public long getOOSize()
public java.util.Map getProperties()
public java.util.Map getHistograms()
public java.util.Map getPatterns()
public java.util.Set getExProperty()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |


The Weather Today
The most accurate forecast
☰
Home
Franklin
Greenville
Springfield
Storm Center
Gallery
Storm Warning
Thanks for reporting a dangerous storm.


In this project, you'll build your first neural network and use it to predict daily bike rental ridership. We've provided some of the code, but left the implementation of the neural network up to you (for the most part). After you've submitted this project, feel free to explore the data and the model more.
%matplotlib inline
%config InlineBackend.figure_format = 'retina'
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
A critical step in working with neural networks is preparing the data correctly. Variables on different scales make it difficult for the network to efficiently learn the correct weights. Below, we've written the code to load and prepare the data. You'll learn more about this soon!
rides = pd.read_csv('Bike-Sharing-Dataset/hour.csv')
rides.head()
This dataset has the number of riders for each hour of each day from January 1 2011 to December 31 2012. The number of riders is split between casual and registered, summed up in the cnt
column. You can see the first few rows of the data above.
Below is a plot showing the number of bike riders over the first 10 days in the data set. You can see the hourly rentals here. This data is pretty complicated! The weekends have lower over all ridership and there are spikes when people are biking to and from work during the week. Looking at the data above, we also have information about temperature, humidity, and windspeed, all of these likely affecting the number of riders. You'll be trying to capture all this with your model.
rides[:24*10].plot(x='dteday', y='cnt')
Here we have some categorical variables like season, weather, month. To include these in our model, we'll need to make binary dummy variables. This is simple to do with Pandas thanks to get_dummies()
.
dummy_fields = ['season', 'weathersit', 'mnth', 'hr', 'weekday']
for each in dummy_fields:
dummies = pd.get_dummies(rides[each], prefix=each, drop_first=False)
rides = pd.concat([rides, dummies], axis=1)
fields_to_drop = ['instant', 'dteday', 'season', 'weathersit',
'weekday', 'atemp', 'mnth', 'workingday', 'hr']
data = rides.drop(fields_to_drop, axis=1)
data.head()
To make training the network easier, we'll standardize each of the continuous variables. That is, we'll shift and scale the variables such that they have zero mean and a standard deviation of 1.
The scaling factors are saved so we can go backwards when we use the network for predictions.
quant_features = ['casual', 'registered', 'cnt', 'temp', 'hum', 'windspeed']
# Store scalings in a dictionary so we can convert back later
scaled_features = {}
for each in quant_features:
mean, std = data[each].mean(), data[each].std()
scaled_features[each] = [mean, std]
data.loc[:, each] = (data[each] - mean)/std
We'll save the last 21 days of the data to use as a validation set after we've trained the network. We'll use this set to make predictions and compare them with the actual number of riders.
# Save the last 21 days
validation = data[-21*24:]
data = data[:-21*24]
# Separate the data into features and targets
target_fields = ['cnt', 'casual', 'registered']
features, targets = data.drop(target_fields, axis=1), data[target_fields]
val_features, val_targets = validation.drop(target_fields, axis=1), validation[target_fields]
We'll split the data into two sets, one for training and one for testing as the network is being trained. It's important to split the data randomly so all cases are represented in both sets.
n_records = features.shape[0]
split = np.random.choice(features.index,
size=int(n_records*0.8),
replace=False)
train_features, train_targets = features.ix[split], targets.ix[split]
test_features, test_targets = features.drop(split), targets.drop(split)
Below you'll build your network. We've built out the structure and the backwards pass. . You'll implement the forward pass through the network. You'll also set the hyperparameters: the learning rate, the number of hidden units, and the number of training passes.
The network has two layers, a hidden layer and an output layer. The hidden layer will use the sigmoid function for activations. The output layer has only one node and is used for the regression, the output of the node is the same as the input of the node. That is, the activation function is f(x)=xf(x)=x . A function that takes the input signal and generates an output signal, but takes into account the threshold, is called an activation function. We work through each layer of our network calculating the outputs for each neuron. All of the outputs from one layer become inputs to the neurons on the next layer. This process is called Forward Propagation.
We use the weights to propagate signals forward from the input to the output layers in a neural network. We use the weights to also propagate error backwards from the output back into the network to update our weights. This is called Backpropagation.
Hint: You'll need the derivative of the output activation function ($f(x) = x$) for the backpropagation implementation. If you aren't familiar with calculus, this function is equivalent to the equation $y = x$. What is the slope of that equation? That is the derivative of $f(x)$.
Below, you have these tasks:
self.activation_function
in __init__
to your sigmoid function.train
method.train
method, including calculating the output error.run
method.class NeuralNetwork:
def __init__(self, input_nodes, hidden_nodes, output_nodes, learning_rate):
# Set number of nodes in input, hidden and output layers.
self.input_nodes = input_nodes
self.hidden_nodes = hidden_nodes
self.output_nodes = output_nodes
# Initialize weights
self.weights_input_to_hidden = np.random.normal(0.0, self.hidden_nodes**-0.5,
(self.hidden_nodes, self.input_nodes))
self.weights_hidden_to_output = np.random.normal(0.0, self.output_nodes**-0.5,
(self.output_nodes, self.hidden_nodes))
self.lr = learning_rate
#### Set this to your implemented sigmoid function ####
# Activation function is the sigmoid function
self.activation_function = lambda x: 1/(1+np.exp(-x))
def train(self, inputs_list, targets_list):
# Convert inputs list to 2d array
inputs = np.array(inputs_list, ndmin=2).T
targets = np.array(targets_list, ndmin = 2).T
#### Implement the forward pass here ####
### Forward pass ###
# Hidden layer
hidden_inputs = np.dot(self.weights_input_to_hidden, inputs)
hidden_outputs = self.activation_function(hidden_inputs)
# Output layer
final_inputs = np.dot(self.weights_hidden_to_output, hidden_outputs)
final_outputs = self.activation_function(final_inputs)
### Backward pass ###
# Output error
output_errors = targets - final_outputs
# Backpropagated error
hidden_errors = np.dot(self.weights_hidden_to_output.T, output_errors)
hidden_grad = hidden_outputs * (1.0 - hidden_outputs)
# Update the weights
self.weights_hidden_to_output += self.lr * np.dot(output_errors,
hidden_outputs.T)
self.weights_input_to_hidden += self.lr * np.dot(hidden_errors * hidden_grad, inputs.T)
def run(self, inputs_list):
# Run a forward pass through the network
inputs = np.array(inputs_list, ndmin=2).T
#### Implement the forward pass here ####
# Hidden layer
hidden_inputs = np.dot(self.weights_input_to_hidden, inputs)
hidden_outputs = self.activation_function(hidden_inputs)
# Output layer
final_inputs = np.dot(self.weights_hidden_to_output, hidden_outputs)
final_outputs = self.activation_function(final_inputs)
return final_outputs
def MSE(y, Y):
return np.mean((y-Y)**2)
Here you'll set the hyperparameters for the network. You'll also be using a method know as Stochastic Gradient Descent (SGD) to train the network. The idea is that for each training pass, you grab a random sample of the data instead of using the whole data set. You use many more training passes than with normal gradient descent, but each pass is much faster. This ends up training the network much faster. You'll learn more about SGD later.
This is the number of times the dataset will pass through the network, each time updating the weights. As the number of epochs increases, the network becomes better and better at predicting the targets in the training set. However, it can become too specific to the training set and will fail to generalize to the test set. This is called overfitting. You'll need to choose enough epochs to train the network well but not too many or you'll be overfitting.
This scales the size of weight updates. If this is too big, the weights tend to explode and the network fails to fit the data. A good choice to start at is 0.1. If the network has problems fitting the data, try reducing the learning rate.
The more hidden nodes you have, the more accurate predictions the model will make. Try a few different numbers and see how it affects the performance. You can look at the losses dictionary for a metric of the network performance.
### Set the hyperparameters here ###
epochs = 10000
learning_rate = 0.001
hidden_nodes = 200
output_nodes = 1
N_i = train_features.shape[1]
network = NeuralNetwork(N_i, hidden_nodes, output_nodes, learning_rate)
losses = {'train':[], 'test':[]}
for e in range(epochs):
# Go through a random batch of 128 records from the training data set
batch = np.random.choice(train_features.index, size=128)
for record, target in zip(train_features.ix[batch].values, train_targets.ix[batch]['cnt']):
network.train(record, target)
if e%(epochs/10) == 0:
# Calculate losses for the training and test sets
train_loss = MSE(network.run(train_features), train_targets['cnt'].values)
test_loss = MSE(network.run(test_features), test_targets['cnt'].values)
losses['train'].append(train_loss)
losses['test'].append(test_loss)
# Print out the losses as the network is training
print('Training loss: {:.4f}'.format(train_loss))
print('Test loss: {:.4f}'.format(test_loss))
pass
plt.plot(losses['train'], label='Training loss')
plt.plot(losses['test'], label='Testing loss')
plt.legend()
Here, use the validation data to check that network is accurately making predictions. If your predictions don't match the data, try adjusting the hyperparameters and check to make sure the forward passes in the network are correct.
fig, ax = plt.subplots(figsize=(8,4))
mean, std = scaled_features['cnt']
predictions = network.run(val_features)*std + mean
ax.plot(predictions[0], label='Prediction')
ax.plot((val_targets['cnt']*std + mean).values, label='Data')
ax.set_xlim(right=len(predictions))
ax.legend()
dates = pd.to_datetime(rides.ix[validation.index]['dteday'])
dates = dates.apply(lambda d: d.strftime('%b %d'))
ax.set_xticks(np.arange(len(dates))[12::24])
_ = ax.set_xticklabels(dates[12::24], rotation=45)
Answer these questions about your results. How well does the model predict the data? Where does it fail? Why does it fail where it does?
Note: You can edit the text in this cell by double clicking on it. When you want to render the text, press control + enter
The model seems to get stuck between two levels. Not really sure whats going on here. I tried adding hidden units to improve the predictions, but it didn't work.


Speleo
Search
Monitoring
Dashboard
Blockboard
Health
Utilities
Settings
Query
Analyze
About
Contact
Logged in as
demo
Search


After you complete this section, you should be able to:
Note that everything in “< >” is to be replaced. For example, <fileName> –> iLovePeanuts.txt
Diffusion weighted imaging is based on water movement within a voxel of tissue. Therefore, the intensity value of each voxel represents the rate of water diffusion at that location. Diffusion tensor imaging is specific type of modeling of diffusion weighted images. The general theory behind DTI is that water molecules diffuse differently along the tissue depending on the tissue’s type and integrity. With DTI analyses it is possible to infer at the level of each voxel properties like molecular diffusion rate (mean diffusivity), the direction preference of diffusion (fractional anisotropy), diffusion along the main axis (axial diffusivity), and diffusion in transverse direction (radial diffusivity).
All DTI preprocessing steps are conducted using the dtiInit preprocessing pipeline wrapper from Stanford open-source VISTASOFT package. The steps of preprocessing any diffusion weighted images includes the following:
First let’s create specific DWI directory within our participant directory. Often times you will be working with multiple scan modalities and you will want to put those in separate directories (e.g., DTI, fMRI, t2w, etc.). This directory is labeled raw and not dti simply because it follows the protocols as written by the Stanford group whose pipeline is being used. You can change the name to something else if you prefer.
Certain scan parameters must also be extracted from the DICOM files in order to determine tensor information in the DWIs. Two files need to be created: b-value file and diffusion gradient table.
The b-values are the amount of diffusion weighting used for each volume. Depending on how many non-diffusion weighted or B0 scans you collect and what diffusion weighting max you use your b-value file is going to look something like this:
Your b-vector are the gradient directions that you collect, often predetermined by the scanner depending on how many total directions you choose to collect. A b-vector file will look something like this:
In dcm2nii
these files are automatically created. However, depending on the brand of the scanner, e.g., Siemens or GE, these scan parameters may not always be applied to the images correctly. Therefore, it is important to always visually check that tensors were applied correctly.
The output from the dcm2nii
program results in file names that are uniquely different across participants. For analyses though, we want all the files named exactly the same from participant to participant. In this case, we want all files to be named exactly the same, dti.nii.gz. The .bvec and .bval files also need to be renamed, dti.bvec and dti.bval, respectively.
Refer to the information provided here: http://njhunsak.github.io/neuroimaging-analysis/topics/preprocessing_T1_weighted_images/. You will need to perform the following steps:
One of the outputs from the antsCorticalThickness.sh pipeline is a skull-stripped image; however, the image is sometimes named differently:
Copy the brain only file into the t1
directory and rename the file brain.nii.gz
:
DTI preprocessing uses a toolbox through MATLAB called VISTASOFT. For more information about how to install VISTASOFT visit https://github.com/vistalab/vistasoft. You will need to set the environment variables for MATLAB to find SPM5, VISTASOFT, and AFQ (which we will discuss later). The order in which you enter these environmental variables is CRITICAL. Do not place vistaPath before SPM5. In MATLAB:
Make sure you have your directory structure set up such that you have:
If you have already processed your T1 files through another pipeline you could have difficulties aligning the DTI data to your T1. This is due to the header information being different from what is expected by the VISTASOFT software. This can be fixed by running (in MATLAB) mrAnatAverageAcpcNifti
. Open MATLAB to update the brain image so it will work in the mrDiffusion pipeline and save the new brain image as aveT1.nii.gz. The T1 image (‘t1/brain.nii.gz’) is rigidly aligned to an MNI template (‘templates/matlab.nii.gz’). Note that this alignment is rather arbitrary and is only useful in establishing the correct header information (e.g. origin, FOV size, etc.):
This section is for those who have collected diffusion data on a Siemens or Phillips scanner, or on a GE scanner using the GE-supplied diffusion sequence (rather than Roland Bammer’s DTI sequence at the Stanford Lucas center). dcm2nii does not properly handle the transforms for use with the VISTASOFT pipeline. To fix this, run a little code in MATLAB that will fix that transform and get things working.
To fix T1 image:
To fix diffusion image:
Specific parameters can be set using the function dtiInitParams:
Note that for Siemens data, we need to change the parameter as follows:
Check parameters. It should look like this:
Running dtiInit is very simple (usually):
… and you’re done! You should have a directory structure that looks something like the following.
If you ever need to place landmarks on the DTI image (e.g. fornix), then it is easiest on an FA image. To generate the FA map, use the following code:
Part of the output provides a file that shows the RGB vector overlay. The file is located under the dt6dir and is called, t1pdd.png. This file shows a montage of the brain with the RGB overlay. The colors of the overlay signify the tensor direction. When looking at DTI overlays, red indicates tensors that are orientated right to left, green indicates tensors that are orientated anterior to posterior, and blue indicates tensors that are orientated superior to inferior. When looking at the RGB overlay, the corpus callosum should be solid red, because the tensors are moving back and forth from the right hemisphere to left hemisphere. If the corpus callosum is not bright red, you know you immediately have an issue:
Depending on the scanner and whether or not dcm2nii properly reads the header information, it is highly probable that the diffusion gradient directions may be reversed. After preprocessing, it is important that you check to make sure the gradient directions are visually inline with the white matter pathways. Here’s an example of misalignment:
If the tensors are aligned correctly, they should like this:


Request Credit
Id
Name
Request Amount
Actions
Id
Name
Phone Number
Approve
Details
Deny
Customer Details
×
Id:
First Name:
Last Name:
Salary:


My name is Naman Manchanda and I am a sophomore at Maharaja Agrasen Institute of Technology. I love to program, develop and contribute. I have been to many hackathons and like hacking.
My mantra : Pull -- Commit -- Push -- Repeat
If you like to collaborate and make something cool, feel free to contact me.
I implemented a decentralised application to create a platform for disaster management. The application employs Machine Learning model to predict the landslide and can create an alert. It also optimises the contact between responsible entities during a time of mishap. It can be used to provide surety that the resources have been transferred to the affected people.
The project is built on Ethereum Blockchain and it brings all the organisations involved in the health insurance sector on the same network. It ensures transparency and prevent fraudulent nature of claims. A clear transparency is maintained between clients, third parties and hospitals. It employs data analysis to check the nature of claim.
I created a gradient background generator while learning gradients in javascript. It is a tutorial available on the Udemy Course.
This is a simple CSS driven responsive web page that uses CSS3's Flexbox. The photos expand on hovering. Flexbox module provides an efficient way to lay out, align and distribute space among items in a container.
This is the simplest implementation to understand a blockchain. I have written the code in Python.


G8 Life 2424 East York Street Suite 202 Philadelphia, PA 19125 Direct:(215)870-5041 Fax:(215)689-0870<EMAIL_ADDRESS>We offer our clients comprehensive solar consulting and installation services, helping Philadelphia, and your wallets, become greener by the moment!
G8 Solar is ISPQ (Institute for Sustainable Power Quality) certified designer/installer as well as a factory-direct dealer of solar components, giving the customer the best possible pricing available. Contact us today for a free estimate and site analysis.


Simple Context
Class de.odysseus.el.util.SimpleContext is a simple context implementation. It can be used at creation time as well as evaluation time.
For use at creation time, it provides the following methods.
- setFunction(String prefix, String name, java.lang.reflect.Method method) to define a method as a function for the given prefix and name. Functions without a namespace must pass in the empty string as prefix. The supplied method must be declared as public and static.
- setVariable(String name, javax.el.ValueExpression expression) to define a value expression as a variable for the given name. (This is equivalent to getVariableMapper().setVariable(String name, javax.el.ValueExpression expression).)
The following example defines function math:sin and variable pi and uses them in an expression.
import javax.el.*; import de.odysseus.el.util.SimpleContext; import de.odysseus.el.ExpressionFactoryImpl; ... ExpressionFactory factory = new ExpressionFactoryImpl(); SimpleContext context = new SimpleContext(); context.setFunction("math", "sin", Math.class.getMethod("sin", double.class)); context.setVariable("pi", factory.createValueExpression(Math.PI, double.class)); ValueExpression expr = factory.createValueExpression(context, "${math:sin(pi/2)}", double.class); System.out.println("math:sin(pi/2) = " + expr.getValue(context)); // 1.0
At evaluation time, a javax.el.ELResolver is required for property resolution and to resolve identifiers, that have not been bound to a variable. The getELResolver() method is used at evaluation time to access the context's resolver instance.
A resolver may be passed to a SimpleContext at construction time. If the default constructor is used, calling getELResolver() will lazily create an instance of de.odysseus.el.util.SimpleResolver.


2 Samuel 22:44
Thou also hast delivered me from the strivings of my people, thou hast kept me to be head of the heathen: a people which I knew not shall serve me.


Related Documents
Selected use cases using the RIS3 Open Data tool of the Online-S3 platform:
Selected RIS3 strategies including the Open Data tool method in their implementation process:
Data Sources
The data presented by the RIS3 Open Data tool has been sourced from the following publishers:
- CORDIS: Community Research and Development Information Service
- Interreg Europe: European Regional Development Fund
- InfoRegio: European Union Regional Policy Programmes


Tab Bucket
Save pages and display one randomly!
Save this page in tab bucket?
Save!
Display random page?
Go!
Include bookmarks
Oh no! You have no saved pages to display. Save a page first!
Manage saved pages


Welcome to Ricardo's Website!
Here, you'll find tons of articles and reviews related to the video games industry,
the anime industry and the likes.
Please enjoy your stay and remember to login to verify your identity!
Rick's Articles: