INSTRUCTION
stringlengths
1
8.43k
RESPONSE
stringlengths
75
104k
Generate a productive CDR3 seq from a Monte Carlo draw of the model.
def gen_rnd_prod_CDR3(self, conserved_J_residues = 'FVW'): """Generate a productive CDR3 seq from a Monte Carlo draw of the model. Parameters ---------- conserved_J_residues : str, optional Conserved amino acid residues defining the CDR3 on the J side (normally F...
Sample the genomic model for VDJ recombination events.
def choose_random_recomb_events(self): """Sample the genomic model for VDJ recombination events. Returns ------- recomb_events : dict Dictionary of the VDJ recombination events. These are integers determining gene choice, deletions, and number of insertions. ...
Generate a productive CDR3 seq from a Monte Carlo draw of the model.
def gen_rnd_prod_CDR3(self, conserved_J_residues = 'FVW'): """Generate a productive CDR3 seq from a Monte Carlo draw of the model. Parameters ---------- conserved_J_residues : str, optional Conserved amino acid residues defining the CDR3 on the J side (normally F...
Sample the genomic model for VDJ recombination events.
def choose_random_recomb_events(self): """Sample the genomic model for VDJ recombination events. Returns ------- recomb_events : dict Dictionary of the VDJ recombination events. These are integers determining gene choice, deletions, and number of insertions. ...
Creates or updates rates for a source
def update_rates(self): """ Creates or updates rates for a source """ source, created = RateSource.objects.get_or_create(name=self.get_source_name()) source.base_currency = self.get_base_currency() source.save() for currency, value in six.iteritems(self.get_rates...
Generate samples from the generalized graph trend filtering distribution via a modified Swendsen - Wang slice sampling algorithm. Options for likelihood: gaussian binomial poisson. Options for prior: laplace doublepareto.
def sample_gtf(data, D, k, likelihood='gaussian', prior='laplace', lambda_hyperparams=None, lam_walk_stdev=0.01, lam0=1., dp_hyperparameter=None, w_hyperparameters=None, iterations=7000, burn=2000, thin=10, robus...
Compute Pgen for all seqs consistent with regular expression regex_seq. Computes Pgen for a ( limited vocabulary ) regular expression of CDR3 amino acid sequences conditioned on the V genes/ alleles indicated in V_usage_mask_in and the J genes/ alleles in J_usage_mask_in. Please note that this function will list out al...
def compute_regex_CDR3_template_pgen(self, regex_seq, V_usage_mask_in = None, J_usage_mask_in = None, print_warnings = True, raise_overload_warning = True): """Compute Pgen for all seqs consistent with regular expression regex_seq. Computes Pgen for a (limited vocabulary) regular expression of CDR3...
Compute Pgen for the amino acid sequence CDR3_seq. Conditioned on the V genes/ alleles indicated in V_usage_mask_in and the J genes/ alleles in J_usage_mask_in. ( Examples are TCRB sequences/ model ) Parameters ---------- CDR3_seq: str CDR3 sequence composed of amino acids -- the standard amino acids plus any custom sy...
def compute_aa_CDR3_pgen(self, CDR3_seq, V_usage_mask_in = None, J_usage_mask_in = None, print_warnings = True): """Compute Pgen for the amino acid sequence CDR3_seq. Conditioned on the V genes/alleles indicated in V_usage_mask_in and the J genes/alleles in J_usage_mask_in. (Examples are T...
Compute Pgen of all seqs hamming dist 1 ( in amino acids ) from CDR3_seq. Please note that this function will list out all the sequences that are hamming distance 1 from the base sequence and then calculate the Pgen of each sequence in succession. THIS CAN BE SLOW as it computes Pgen for L + 1 sequences where L = len (...
def compute_hamming_dist_1_pgen(self, CDR3_seq, V_usage_mask_in = None, J_usage_mask_in = None, print_warnings = True): """Compute Pgen of all seqs hamming dist 1 (in amino acids) from CDR3_seq. Please note that this function will list out all the sequences that are hamming distance 1 from...
Compute Pgen for the inframe nucleotide sequence CDR3_ntseq. Conditioned on the V genes/ alleles indicated in V_usage_mask_in and the J genes/ alleles in J_usage_mask_in. ( Examples are TCRB sequences/ model ) Parameters ---------- CDR3_ntseq: str Inframe nucleotide sequence composed of ONLY A C G or T ( either upperca...
def compute_nt_CDR3_pgen(self, CDR3_ntseq, V_usage_mask_in = None, J_usage_mask_in = None, print_warnings = True): """Compute Pgen for the inframe nucleotide sequence CDR3_ntseq. Conditioned on the V genes/alleles indicated in V_usage_mask_in and the J genes/alleles in J_usage_mask_in. (Ex...
Format raw usage masks into lists of indices. Usage masks allows the Pgen computation to be conditioned on the V and J gene/ allele identities. The inputted masks are lists of strings or a single string of the names of the genes or alleles to be conditioned on. The default mask includes all productive V or J genes. Par...
def format_usage_masks(self, V_usage_mask_in, J_usage_mask_in, print_warnings = True): """Format raw usage masks into lists of indices. Usage masks allows the Pgen computation to be conditioned on the V and J gene/allele identities. The inputted masks are lists of strings, or a si...
List sequences that match regular expression template. This function parses a limited regular expression vocabulary and lists all the sequences consistent with the regular expression. Supported regex syntax: [] and {}. Cannot have two {} in a row. Note we can t use Kline star ( * ) as this is the symbol for a stop codo...
def list_seqs_from_regex(self, regex_seq, print_warnings = True, raise_overload_warning = True): """List sequences that match regular expression template. This function parses a limited regular expression vocabulary, and lists all the sequences consistent with the regular expression. Suppo...
Find maximum match between CDR3_seq and ntseq from the left. This function returns the length of the maximum length nucleotide subsequence of ntseq contiguous from the left ( or 5 end ) that is consistent with the amino acid sequence CDR3_seq. Parameters ---------- CDR3_seq: str CDR3 sequence composed of amino acids ( ...
def max_nt_to_aa_alignment_left(self, CDR3_seq, ntseq): """Find maximum match between CDR3_seq and ntseq from the left. This function returns the length of the maximum length nucleotide subsequence of ntseq contiguous from the left (or 5' end) that is consistent with the 'amino...
Find maximum match between CDR3_seq and ntseq from the right. This function returns the length of the maximum length nucleotide subsequence of ntseq contiguous from the right ( or 3 end ) that is consistent with the amino acid sequence CDR3_seq Parameters ---------- CDR3_seq: str CDR3 sequence composed of amino acids (...
def max_nt_to_aa_alignment_right(self, CDR3_seq, ntseq): """Find maximum match between CDR3_seq and ntseq from the right. This function returns the length of the maximum length nucleotide subsequence of ntseq contiguous from the right (or 3' end) that is consistent with the 'amino ...
Compute Pgen for CDR3 amino acid sequence CDR3_seq from VDJ model. Conditioned on the already formatted V genes/ alleles indicated in V_usage_mask and the J genes/ alleles in J_usage_mask. ( Examples are TCRB sequences/ model ) Parameters ---------- CDR3_seq: str CDR3 sequence composed of amino acids ( single character...
def compute_CDR3_pgen(self, CDR3_seq, V_usage_mask, J_usage_mask): """Compute Pgen for CDR3 'amino acid' sequence CDR3_seq from VDJ model. Conditioned on the already formatted V genes/alleles indicated in V_usage_mask and the J genes/alleles in J_usage_mask. (Examples are TCRB seq...
Compute Pi_V. This function returns the Pi array from the model factors of the V genomic contributions P ( V ) * P ( delV|V ). This corresponds to V_ { x_1 }. For clarity in parsing the algorithm implementation we include which instance attributes are used in the method as parameters. Parameters ---------- CDR3_seq: st...
def compute_Pi_V(self, CDR3_seq, V_usage_mask): """Compute Pi_V. This function returns the Pi array from the model factors of the V genomic contributions, P(V)*P(delV|V). This corresponds to V_{x_1}. For clarity in parsing the algorithm implementation, we include which ...
Compute Pi_L. This function returns the Pi array from the model factors of the V genomic contributions P ( V ) * P ( delV|V ) and the VD ( N1 ) insertions first_nt_bias_insVD ( m_1 ) PinsVD ( \ ell_ { VD } ) \ prod_ { i = 2 } ^ { \ ell_ { VD }} Rvd ( m_i|m_ { i - 1 } ). This corresponds to V_ { x_1 } { M^ { x_1 }} _ { ...
def compute_Pi_L(self, CDR3_seq, Pi_V, max_V_align): """Compute Pi_L. This function returns the Pi array from the model factors of the V genomic contributions, P(V)*P(delV|V), and the VD (N1) insertions, first_nt_bias_insVD(m_1)PinsVD(\ell_{VD})\prod_{i=2}^{\ell_{VD}}Rvd(m_i|m_{i-1...
Compute Pi_J conditioned on D. This function returns the Pi array from the model factors of the D and J genomic contributions P ( D J ) * P ( delJ|J ) = P ( D|J ) P ( J ) P ( delJ|J ). This corresponds to J ( D ) ^ { x_4 }. For clarity in parsing the algorithm implementation we include which instance attributes are use...
def compute_Pi_J_given_D(self, CDR3_seq, J_usage_mask): """Compute Pi_J conditioned on D. This function returns the Pi array from the model factors of the D and J genomic contributions, P(D, J)*P(delJ|J) = P(D|J)P(J)P(delJ|J). This corresponds to J(D)^{x_4}. For c...
Compute Pi_JinsDJ conditioned on D. This function returns the Pi array from the model factors of the J genomic contributions P ( D J ) * P ( delJ|J ) and the DJ ( N2 ) insertions first_nt_bias_insDJ ( n_1 ) PinsDJ ( \ ell_ { DJ } ) \ prod_ { i = 2 } ^ { \ ell_ { DJ }} Rdj ( n_i|n_ { i - 1 } ) conditioned on D identity....
def compute_Pi_JinsDJ_given_D(self, CDR3_seq, Pi_J_given_D, max_J_align): """Compute Pi_JinsDJ conditioned on D. This function returns the Pi array from the model factors of the J genomic contributions, P(D,J)*P(delJ|J), and the DJ (N2) insertions, first_nt_bias_insDJ(n_1)PinsDJ(\e...
Compute Pi_R. This function returns the Pi array from the model factors of the D and J genomic contributions P ( D J ) * P ( delJ|J ) P ( delDl delDr |D ) and the DJ ( N2 ) insertions first_nt_bias_insDJ ( n_1 ) PinsDJ ( \ ell_ { DJ } ) \ prod_ { i = 2 } ^ { \ ell_ { DJ }} Rdj ( n_i|n_ { i - 1 } ). This corresponds to ...
def compute_Pi_R(self, CDR3_seq, Pi_JinsDJ_given_D): """Compute Pi_R. This function returns the Pi array from the model factors of the D and J genomic contributions, P(D, J)*P(delJ|J)P(delDl, delDr |D) and the DJ (N2) insertions, first_nt_bias_insDJ(n_1)PinsDJ(\ell_{DJ})\pr...
Compute Pgen for CDR3 amino acid sequence CDR3_seq from VJ model. Conditioned on the already formatted V genes/ alleles indicated in V_usage_mask and the J genes/ alleles in J_usage_mask. Parameters ---------- CDR3_seq: str CDR3 sequence composed of amino acids ( single character symbols each corresponding to a collect...
def compute_CDR3_pgen(self, CDR3_seq, V_usage_mask, J_usage_mask): """Compute Pgen for CDR3 'amino acid' sequence CDR3_seq from VJ model. Conditioned on the already formatted V genes/alleles indicated in V_usage_mask and the J genes/alleles in J_usage_mask. Parameters ...
Compute Pi_V conditioned on J. This function returns the Pi array from the model factors of the V genomic contributions P ( V J ) * P ( delV|V ). This corresponds to V ( J ) _ { x_1 }. For clarity in parsing the algorithm implementation we include which instance attributes are used in the method as parameters. Paramete...
def compute_Pi_V_given_J(self, CDR3_seq, V_usage_mask, J_usage_mask): """Compute Pi_V conditioned on J. This function returns the Pi array from the model factors of the V genomic contributions, P(V, J)*P(delV|V). This corresponds to V(J)_{x_1}. For clarity in parsing the a...
Compute Pi_V_insVJ conditioned on J. This function returns the Pi array from the model factors of the V genomic contributions P ( V J ) * P ( delV|V ) and the VJ ( N ) insertions first_nt_bias_insVJ ( m_1 ) PinsVJ ( \ ell_ { VJ } ) \ prod_ { i = 2 } ^ { \ ell_ { VJ }} Rvj ( m_i|m_ { i - 1 } ). This corresponds to V ( J...
def compute_Pi_V_insVJ_given_J(self, CDR3_seq, Pi_V_given_J, max_V_align): """Compute Pi_V_insVJ conditioned on J. This function returns the Pi array from the model factors of the V genomic contributions, P(V, J)*P(delV|V), and the VJ (N) insertions, first_nt_bias_insVJ(m_1)PinsVJ(...
Compute Pi_J. This function returns the Pi array from the model factors of the J genomic contributions P ( delJ|J ). This corresponds to J ( D ) ^ { x_4 }. For clarity in parsing the algorithm implementation we include which instance attributes are used in the method as parameters. Parameters ---------- CDR3_seq: str C...
def compute_Pi_J(self, CDR3_seq, J_usage_mask): """Compute Pi_J. This function returns the Pi array from the model factors of the J genomic contributions, P(delJ|J). This corresponds to J(D)^{x_4}. For clarity in parsing the algorithm implementation, we include which ...
Solves the GFL for a fixed value of lambda.
def solve(self, lam): '''Solves the GFL for a fixed value of lambda.''' s = weighted_graphtf(self.nnodes, self.y, self.weights, lam, self.Dk.shape[0], self.Dk.shape[1], self.Dk.nnz, self.Dk.row.astype('int32'), self.Dk.col.astype('int32'), self.D...
Follows the solution path to find the best lambda value.
def solution_path(self, min_lambda, max_lambda, lambda_bins, verbose=0): '''Follows the solution path to find the best lambda value.''' self.u = np.zeros(self.Dk.shape[0], dtype='double') lambda_grid = np.exp(np.linspace(np.log(max_lambda), np.log(min_lambda), lambda_bins)) aic_trace = n...
Solves the GFL for a fixed value of lambda.
def solve(self, lam): '''Solves the GFL for a fixed value of lambda.''' s = weighted_graphtf_logit(self.nnodes, self.trials, self.successes, lam, self.Dk.shape[0], self.Dk.shape[1], self.Dk.nnz, self.Dk.row.astype('int32'), self.Dk.col.as...
Solves the GFL for a fixed value of lambda.
def solve(self, lam): '''Solves the GFL for a fixed value of lambda.''' s = weighted_graphtf_poisson(self.nnodes, self.obs, lam, self.Dk.shape[0], self.Dk.shape[1], self.Dk.nnz, self.Dk.row.astype('int32'), self.Dk.col.astype('int32'), se...
Constructs the V and J mask mapping dictionaries. Parameters ---------- genV: list List of genomic V information. genJ: list List of genomic J information.
def make_V_and_J_mask_mapping(self, genV, genJ): """Constructs the V and J mask mapping dictionaries. Parameters ---------- genV : list List of genomic V information. genJ : list List of genomic J information. """ ...
Process P ( delDl delDr|D ) into Pi arrays. Sets the attributes PD_nt_pos_vec PD_2nd_nt_pos_per_aa_vec min_delDl_given_DdelDr max_delDl_given_DdelDr and zeroD_given_D. Parameters ---------- generative_model: GenerativeModelVDJ VDJ generative model class containing the model parameters. genomic_data: GenomicDataVDJ VDJ ...
def preprocess_D_segs(self, generative_model, genomic_data): """Process P(delDl, delDr|D) into Pi arrays. Sets the attributes PD_nt_pos_vec, PD_2nd_nt_pos_per_aa_vec, min_delDl_given_DdelDr, max_delDl_given_DdelDr, and zeroD_given_D. Parameters ---------- g...
Process P ( J ) * P ( delJ|J ) into Pi arrays. Sets the attributes PJdelJ_nt_pos_vec and PJdelJ_2nd_nt_pos_per_aa_vec. Parameters ---------- generative_model: GenerativeModelVDJ VDJ generative model class containing the model parameters. genomic_data: GenomicDataVDJ VDJ genomic data class containing the V D and J germl...
def generate_PJdelJ_nt_pos_vecs(self, generative_model, genomic_data): """Process P(J)*P(delJ|J) into Pi arrays. Sets the attributes PJdelJ_nt_pos_vec and PJdelJ_2nd_nt_pos_per_aa_vec. Parameters ---------- generative_model : GenerativeModelVDJ VDJ gener...
Compute the transfer matrices for the VD junction. Sets the attributes Tvd Svd Dvd lTvd and lDvd.
def generate_VD_junction_transfer_matrices(self): """Compute the transfer matrices for the VD junction. Sets the attributes Tvd, Svd, Dvd, lTvd, and lDvd. """ nt2num = {'A': 0, 'C': 1, 'G': 2, 'T': 3} #Compute Tvd Tvd ...
Compute the transfer matrices for the VD junction. Sets the attributes Tdj Sdj Ddj rTdj and rDdj.
def generate_DJ_junction_transfer_matrices(self): """Compute the transfer matrices for the VD junction. Sets the attributes Tdj, Sdj, Ddj, rTdj, and rDdj. """ nt2num = {'A': 0, 'C': 1, 'G': 2, 'T': 3} #Compute Tdj Tdj = {} for aa...
Process P ( delV|V ) into Pi arrays. Set the attributes PVdelV_nt_pos_vec and PVdelV_2nd_nt_pos_per_aa_vec. Parameters ---------- generative_model: GenerativeModelVJ VJ generative model class containing the model parameters. genomic_data: GenomicDataVJ VJ genomic data class containing the V and J germline sequences and...
def generate_PVdelV_nt_pos_vecs(self, generative_model, genomic_data): """Process P(delV|V) into Pi arrays. Set the attributes PVdelV_nt_pos_vec and PVdelV_2nd_nt_pos_per_aa_vec. Parameters ---------- generative_model : GenerativeModelVJ VJ generative mo...
Process P ( delJ|J ) into Pi arrays. Set the attributes PJdelJ_nt_pos_vec and PJdelJ_2nd_nt_pos_per_aa_vec. Parameters ---------- generative_model: GenerativeModelVJ VJ generative model class containing the model parameters. genomic_data: GenomicDataVJ VJ genomic data class containing the V and J germline sequences and...
def generate_PJdelJ_nt_pos_vecs(self, generative_model, genomic_data): """Process P(delJ|J) into Pi arrays. Set the attributes PJdelJ_nt_pos_vec and PJdelJ_2nd_nt_pos_per_aa_vec. Parameters ---------- generative_model : GenerativeModelVJ VJ generative mo...
Compute the transfer matrices for the VJ junction. Sets the attributes Tvj Svj Dvj lTvj and lDvj.
def generate_VJ_junction_transfer_matrices(self): """Compute the transfer matrices for the VJ junction. Sets the attributes Tvj, Svj, Dvj, lTvj, and lDvj. """ nt2num = {'A': 0, 'C': 1, 'G': 2, 'T': 3} #Compute Tvj Tv...
Prints IMAGE_DOS_HEADER fields.
def showDosHeaderData(peInstance): """ Prints IMAGE_DOS_HEADER fields. """ dosFields = peInstance.dosHeader.getFields() print "[+] IMAGE_DOS_HEADER values:\n" for field in dosFields: if isinstance(dosFields[field], datatypes.Array): print "--> %s - Array of length %d" % (field,...
Prints IMAGE_FILE_HEADER fields.
def showFileHeaderData(peInstance): """ Prints IMAGE_FILE_HEADER fields. """ fileHeaderFields = peInstance.ntHeaders.fileHeader.getFields() print "[+] IMAGE_FILE_HEADER values:\n" for field in fileHeaderFields: print "--> %s = 0x%08x" % (field, fileHeaderFields[field].value)
Prints IMAGE_OPTIONAL_HEADER fields.
def showOptionalHeaderData(peInstance): """ Prints IMAGE_OPTIONAL_HEADER fields. """ print "[+] IMAGE_OPTIONAL_HEADER:\n" ohFields = peInstance.ntHeaders.optionalHeader.getFields() for field in ohFields: if not isinstance(ohFields[field], datadirs.DataDirectory): print "--> %s ...
Prints the DATA_DIRECTORY fields.
def showDataDirectoriesData(peInstance): """ Prints the DATA_DIRECTORY fields. """ print "[+] Data directories:\n" dirs = peInstance.ntHeaders.optionalHeader.dataDirectory counter = 1 for dir in dirs: print "[%d] --> Name: %s -- RVA: 0x%08x -- SIZE: 0x%08x" % (counter, dir.name.value, ...
Prints IMAGE_SECTION_HEADER for every section present in the file.
def showSectionsHeaders(peInstance): """ Prints IMAGE_SECTION_HEADER for every section present in the file. """ print "[+] Sections information:\n" print "--> NumberOfSections: %d\n" % peInstance.ntHeaders.fileHeader.numberOfSections.value for section in peInstance.sectionHeaders: fields = ...
Shows imports information.
def showImports(peInstance): """ Shows imports information. """ iidEntries = peInstance.ntHeaders.optionalHeader.dataDirectory[consts.IMPORT_DIRECTORY].info if iidEntries: for iidEntry in iidEntries: fields = iidEntry.getFields() print "module: %s" % iidEntry.metaData.mo...
Show exports information
def showExports(peInstance): """ Show exports information """ exports = peInstance.ntHeaders.optionalHeader.dataDirectory[consts.EXPORT_DIRECTORY].info if exports: exp_fields = exports.getFields() for field in exp_fields: print "%s -> %x" % (field, exp_fields[field].value) ...
Returns all the class attributues.
def getFields(self): """ Returns all the class attributues. @rtype: dict @return: A dictionary containing all the class attributes. """ d = {} for i in self._attrsList: key = i value = getattr(self, i) d[key] = value ...
Returns a new L { Array } object.
def parse(readDataInstance, arrayType, arrayLength): """ Returns a new L{Array} object. @type readDataInstance: L{ReadData} @param readDataInstance: The L{ReadData} object containing the array data. @type arrayType: int @param arrayType: The type of L{...
Calculates an Euler tour over the graph g from vertex start to vertex end. Assumes start and end are odd - degree vertices and that there are no other odd - degree vertices.
def calc_euler_tour(g, start, end): '''Calculates an Euler tour over the graph g from vertex start to vertex end. Assumes start and end are odd-degree vertices and that there are no other odd-degree vertices.''' even_g = nx.subgraph(g, g.nodes()).copy() if end in even_g.neighbors(start): # I...
Greedily select trails by making the longest you can until the end
def greedy_trails(subg, odds, verbose): '''Greedily select trails by making the longest you can until the end''' if verbose: print('\tCreating edge map') edges = defaultdict(list) for x,y in subg.edges(): edges[x].append(y) edges[y].append(x) if verbose: print('\tS...
Decompose a graph into a set of non - overlapping trails.
def decompose_graph(g, heuristic='tour', max_odds=20, verbose=0): '''Decompose a graph into a set of non-overlapping trails.''' # Get the connected subgraphs subgraphs = [nx.subgraph(g, x).copy() for x in nx.connected_components(g)] chains = [] num_subgraphs = len(subgraphs) step = 0 while ...
Add.
def plus(self, a): """ Add. """ return Vector(self.x+a.x, self.y+a.y, self.z+a.z)
Subtract.
def minus(self, a): """ Subtract. """ return Vector(self.x-a.x, self.y-a.y, self.z-a.z)
Multiply.
def times(self, a): """ Multiply. """ return Vector(self.x*a, self.y*a, self.z*a)
Divide.
def dividedBy(self, a): """ Divide. """ return Vector(self.x/a, self.y/a, self.z/a)
Lerp. Linear interpolation from self to a
def lerp(self, a, t): """ Lerp. Linear interpolation from self to a""" return self.plus(a.minus(self).times(t));
Create a new vertex between this vertex and other by linearly interpolating all properties using a parameter of t. Subclasses should override this to interpolate additional properties.
def interpolate(self, other, t): """ Create a new vertex between this vertex and `other` by linearly interpolating all properties using a parameter of `t`. Subclasses should override this to interpolate additional properties. """ return Vertex(self.pos.lerp(other.pos, t),...
Split polygon by this plane if needed then put the polygon or polygon fragments in the appropriate lists. Coplanar polygons go into either coplanarFront or coplanarBack depending on their orientation with respect to this plane. Polygons in front or in back of this plane go into either front or back
def splitPolygon(self, polygon, coplanarFront, coplanarBack, front, back): """ Split `polygon` by this plane if needed, then put the polygon or polygon fragments in the appropriate lists. Coplanar polygons go into either `coplanarFront` or `coplanarBack` depending on their orientation wi...
Convert solid space to empty space and empty space to solid space.
def invert(self): """ Convert solid space to empty space and empty space to solid space. """ for poly in self.polygons: poly.flip() self.plane.flip() if self.front: self.front.invert() if self.back: self.back.invert() ...
Recursively remove all polygons in polygons that are inside this BSP tree.
def clipPolygons(self, polygons): """ Recursively remove all polygons in `polygons` that are inside this BSP tree. """ if not self.plane: return polygons[:] front = [] back = [] for poly in polygons: self.plane.splitPolygon(poly,...
Remove all polygons in this BSP tree that are inside the other BSP tree bsp.
def clipTo(self, bsp): """ Remove all polygons in this BSP tree that are inside the other BSP tree `bsp`. """ self.polygons = bsp.clipPolygons(self.polygons) if self.front: self.front.clipTo(bsp) if self.back: self.back.clipTo(bsp)
Return a list of all polygons in this BSP tree.
def allPolygons(self): """ Return a list of all polygons in this BSP tree. """ polygons = self.polygons[:] if self.front: polygons.extend(self.front.allPolygons()) if self.back: polygons.extend(self.back.allPolygons()) return polygons
Build a BSP tree out of polygons. When called on an existing tree the new polygons are filtered down to the bottom of the tree and become new nodes there. Each set of polygons is partitioned using the first polygon ( no heuristic is used to pick a good split ).
def build(self, polygons): """ Build a BSP tree out of `polygons`. When called on an existing tree, the new polygons are filtered down to the bottom of the tree and become new nodes there. Each set of polygons is partitioned using the first polygon (no heuristic is used to pick a...
Returns the rate from the default currency to currency.
def get_rate(currency): """Returns the rate from the default currency to `currency`.""" source = get_rate_source() try: return Rate.objects.get(source=source, currency=currency).value except Rate.DoesNotExist: raise CurrencyConversionException( "Rate for %s in %s do not exist...
Get the default Rate Source and return it.
def get_rate_source(): """Get the default Rate Source and return it.""" backend = money_rates_settings.DEFAULT_BACKEND() try: return RateSource.objects.get(name=backend.get_source_name()) except RateSource.DoesNotExist: raise CurrencyConversionException( "Rate for %s source d...
Convert amount from currency_from to currency_to
def base_convert_money(amount, currency_from, currency_to): """ Convert 'amount' from 'currency_from' to 'currency_to' """ source = get_rate_source() # Get rate for currency_from. if source.base_currency != currency_from: rate_from = get_rate(currency_from) else: # If curren...
Convert amount from currency_from to currency_to and return a Money instance of the converted amount.
def convert_money(amount, currency_from, currency_to): """ Convert 'amount' from 'currency_from' to 'currency_to' and return a Money instance of the converted amount. """ new_amount = base_convert_money(amount, currency_from, currency_to) return moneyed.Money(new_amount, currency_to)
Format a datetime object with Java SimpleDateFormat s - like string.
def format_date(format_string=None, datetime_obj=None): """ Format a datetime object with Java SimpleDateFormat's-like string. If datetime_obj is not given - use current datetime. If format_string is not given - return number of millisecond since epoch. :param format_string: :param datetime_ob...
Tries to determine if a buffer is empty.
def allZero(buffer): """ Tries to determine if a buffer is empty. @type buffer: str @param buffer: Buffer to test if it is empty. @rtype: bool @return: C{True} if the given buffer is empty, i.e. full of zeros, C{False} if it doesn't. """ allZero = True for byte ...
Writes a byte into the L { WriteData } stream object.
def writeByte(self, byte): """ Writes a byte into the L{WriteData} stream object. @type byte: int @param byte: Byte value to write into the stream. """ self.data.write(pack("B" if not self.signed else "b", byte))
Writes a word value into the L { WriteData } stream object.
def writeWord(self, word): """ Writes a word value into the L{WriteData} stream object. @type word: int @param word: Word value to write into the stream. """ self.data.write(pack(self.endianness + ("H" if not self.signed else "h"), word))
Writes a dword value into the L { WriteData } stream object.
def writeDword(self, dword): """ Writes a dword value into the L{WriteData} stream object. @type dword: int @param dword: Dword value to write into the stream. """ self.data.write(pack(self.endianness + ("L" if not self.signed else "l"), dword))
Writes a qword value into the L { WriteData } stream object.
def writeQword(self, qword): """ Writes a qword value into the L{WriteData} stream object. @type qword: int @param qword: Qword value to write into the stream. """ self.data.write(pack(self.endianness + ("Q" if not self.signed else "q"), qword))
Sets the offset of the L { WriteData } stream object in wich the data is written.
def setOffset(self, value): """ Sets the offset of the L{WriteData} stream object in wich the data is written. @type value: int @param value: Integer value that represent the offset we want to start writing in the L{WriteData} stream. @raise WrongOffsetValue...
Skips the specified number as parameter to the current value of the L { WriteData } stream.
def skipBytes(self, nroBytes): """ Skips the specified number as parameter to the current value of the L{WriteData} stream. @type nroBytes: int @param nroBytes: The number of bytes to skip. """ self.data.seek(nroBytes + self.data.tell())
Reads a dword value from the L { ReadData } stream object.
def readDword(self): """ Reads a dword value from the L{ReadData} stream object. @rtype: int @return: The dword value read from the L{ReadData} stream. """ dword = unpack(self.endianness + ('L' if not self.signed else 'l'), self.readAt(self.offset, 4))[0] ...
Reads a word value from the L { ReadData } stream object.
def readWord(self): """ Reads a word value from the L{ReadData} stream object. @rtype: int @return: The word value read from the L{ReadData} stream. """ word = unpack(self.endianness + ('H' if not self.signed else 'h'), self.readAt(self.offset, 2))[0] sel...
Reads a byte value from the L { ReadData } stream object.
def readByte(self): """ Reads a byte value from the L{ReadData} stream object. @rtype: int @return: The byte value read from the L{ReadData} stream. """ byte = unpack('B' if not self.signed else 'b', self.readAt(self.offset, 1))[0] self.offset += 1 ...
Reads a qword value from the L { ReadData } stream object.
def readQword(self): """ Reads a qword value from the L{ReadData} stream object. @rtype: int @return: The qword value read from the L{ReadData} stream. """ qword = unpack(self.endianness + ('Q' if not self.signed else 'b'), self.readAt(self.offset, 8))[0] ...
Reads an ASCII string from the L { ReadData } stream object.
def readString(self): """ Reads an ASCII string from the L{ReadData} stream object. @rtype: str @return: An ASCII string read form the stream. """ resultStr = "" while self.data[self.offset] != "\x00": resultStr += self.data[self.offset] ...
Reads an ASCII string aligned to the next align - bytes boundary.
def readAlignedString(self, align = 4): """ Reads an ASCII string aligned to the next align-bytes boundary. @type align: int @param align: (Optional) The value we want the ASCII string to be aligned. @rtype: str @return: A 4-bytes aligned (default) ASCI...
Reads data from the L { ReadData } stream object.
def read(self, nroBytes): """ Reads data from the L{ReadData} stream object. @type nroBytes: int @param nroBytes: The number of bytes to read. @rtype: str @return: A string containing the read data from the L{ReadData} stream object. @ra...
Reads as many bytes indicated in the size parameter at the specific offset.
def readAt(self, offset, size): """ Reads as many bytes indicated in the size parameter at the specific offset. @type offset: int @param offset: Offset of the value to be read. @type size: int @param size: This parameter indicates how many bytes are going to be read fro...
Send a notification to channels
def send(self, message, channel_name=None, fail_silently=False, options=None): # type: (Text, Optional[str], bool, Optional[SendOptions]) -> None """Send a notification to channels :param message: A message """ if channel_name is None: channels = self.se...
Prepares and sends an HTTP request. Returns the HTTPResponse object.
def request(self, method, path, params=None, headers=None, cookies=None, data=None, json=None, allow_redirects=None, timeout=None): """ Prepares and sends an HTTP request. Returns the HTTPResponse object. :param method: str :param path: str :return: response ...
Read anchor position and functionality from file.
def load_genomic_CDR3_anchor_pos_and_functionality(anchor_pos_file_name): """Read anchor position and functionality from file. Parameters ---------- anchor_pos_file_name : str File name for the functionality and position of a conserved residue that defines the CDR3 region for each V or...
Load raw genV from file. genV is a list of genomic V information. Each element is a list of three elements. The first is the name of the V allele the second is the genomic sequence trimmed to the CDR3 region for productive sequences and the last is the full germline sequence. For this raw genV the middle element is an ...
def read_igor_V_gene_parameters(params_file_name): """Load raw genV from file. genV is a list of genomic V information. Each element is a list of three elements. The first is the name of the V allele, the second is the genomic sequence trimmed to the CDR3 region for productive sequences, and the ...
Load genD from file. genD is a list of genomic D information. Each element is a list of the name of the D allele and the germline sequence.
def read_igor_D_gene_parameters(params_file_name): """Load genD from file. genD is a list of genomic D information. Each element is a list of the name of the D allele and the germline sequence. Parameters ---------- params_file_name : str File name for a IGOR parameter file. R...
Load raw genJ from file. genJ is a list of genomic J information. Each element is a list of three elements. The first is the name of the J allele the second is the genomic sequence trimmed to the CDR3 region for productive sequences and the last is the full germline sequence. For this raw genJ the middle element is an ...
def read_igor_J_gene_parameters(params_file_name): """Load raw genJ from file. genJ is a list of genomic J information. Each element is a list of three elements. The first is the name of the J allele, the second is the genomic sequence trimmed to the CDR3 region for productive sequences, and the ...
Load raw IGoR model marginals. Parameters ---------- marginals_file_name: str File name for a IGOR model marginals file.
def read_igor_marginals_txt(marginals_file_name , dim_names=False): """Load raw IGoR model marginals. Parameters ---------- marginals_file_name : str File name for a IGOR model marginals file. Returns ------- model_dict : dict Dictionary with model marginals. dimens...
Trim V and J germline sequences to the CDR3 region. Unproductive sequences have an empty string for the CDR3 region sequence. Edits the attributes genV and genJ Parameters ---------- V_anchor_pos_file_name: str File name for the conserved residue ( C ) locations and functionality of each V genomic sequence. J_anchor_po...
def anchor_and_curate_genV_and_genJ(self, V_anchor_pos_file, J_anchor_pos_file): """Trim V and J germline sequences to the CDR3 region. Unproductive sequences have an empty string '' for the CDR3 region sequence. Edits the attributes genV and genJ Param...
Add palindromic inserted nucleotides to germline V sequences. The maximum number of palindromic insertions are appended to the germline V segments so that delV can index directly for number of nucleotides to delete from a segment. Sets the attribute cutV_genomic_CDR3_segs.
def generate_cutV_genomic_CDR3_segs(self): """Add palindromic inserted nucleotides to germline V sequences. The maximum number of palindromic insertions are appended to the germline V segments so that delV can index directly for number of nucleotides to delete from a segment. ...
Add palindromic inserted nucleotides to germline J sequences. The maximum number of palindromic insertions are appended to the germline J segments so that delJ can index directly for number of nucleotides to delete from a segment. Sets the attribute cutJ_genomic_CDR3_segs.
def generate_cutJ_genomic_CDR3_segs(self): """Add palindromic inserted nucleotides to germline J sequences. The maximum number of palindromic insertions are appended to the germline J segments so that delJ can index directly for number of nucleotides to delete from a segment. ...
Set attributes by loading in genomic data from IGoR parameter file. Sets attributes genV max_delV_palindrome cutV_genomic_CDR3_segs genD max_delDl_palindrome max_delDr_palindrome cutD_genomic_CDR3_segs genJ max_delJ_palindrome and cutJ_genomic_CDR3_segs. Parameters ---------- params_file_name: str File name for a IGOR ...
def load_igor_genomic_data(self, params_file_name, V_anchor_pos_file, J_anchor_pos_file): """Set attributes by loading in genomic data from IGoR parameter file. Sets attributes genV, max_delV_palindrome, cutV_genomic_CDR3_segs, genD, max_delDl_palindrome, max_delDr_palindrome, ...
Add palindromic inserted nucleotides to germline V sequences. The maximum number of palindromic insertions are appended to the germline D segments so that delDl and delDr can index directly for number of nucleotides to delete from a segment. Sets the attribute cutV_genomic_CDR3_segs.
def generate_cutD_genomic_CDR3_segs(self): """Add palindromic inserted nucleotides to germline V sequences. The maximum number of palindromic insertions are appended to the germline D segments so that delDl and delDr can index directly for number of nucleotides to delete from a...
Read V D and J palindrome parameters from file. Sets the attributes max_delV_palindrome max_delDl_palindrome max_delDr_palindrome and max_delJ_palindrome. Parameters ---------- params_file_name: str File name for an IGoR parameter file of a VDJ generative model.
def read_VDJ_palindrome_parameters(self, params_file_name): """Read V, D, and J palindrome parameters from file. Sets the attributes max_delV_palindrome, max_delDl_palindrome, max_delDr_palindrome, and max_delJ_palindrome. Parameters ---------- params_file_n...
Set attributes by loading in genomic data from IGoR parameter file. Sets attributes genV genJ max_delV_palindrome max_delJ_palindrome cutV_genomic_CDR3_segs and cutJ_genomic_CDR3_segs. Parameters ---------- params_file_name: str File name for a IGOR parameter file. V_anchor_pos_file_name: str File name for the conserve...
def load_igor_genomic_data(self, params_file_name, V_anchor_pos_file, J_anchor_pos_file): """Set attributes by loading in genomic data from IGoR parameter file. Sets attributes genV, genJ, max_delV_palindrome, max_delJ_palindrome, cutV_genomic_CDR3_segs, and cutJ_genomic_CDR3_segs. ...
Read V and J palindrome parameters from file. Sets the attributes max_delV_palindrome and max_delJ_palindrome. Parameters ---------- params_file_name: str File name for an IGoR parameter file of a VJ generative model.
def read_igor_VJ_palindrome_parameters(self, params_file_name): """Read V and J palindrome parameters from file. Sets the attributes max_delV_palindrome and max_delJ_palindrome. Parameters ---------- params_file_name : str File name for an IGoR parameter...
Set attributes by reading a generative model from IGoR marginal file. Sets attributes PV PdelV_given_V PDJ PdelJ_given_J PdelDldelDr_given_D PinsVD PinsDJ Rvd and Rdj. Parameters ---------- marginals_file_name: str File name for a IGoR model marginals file.
def load_and_process_igor_model(self, marginals_file_name): """Set attributes by reading a generative model from IGoR marginal file. Sets attributes PV, PdelV_given_V, PDJ, PdelJ_given_J, PdelDldelDr_given_D, PinsVD, PinsDJ, Rvd, and Rdj. Parameters ---------- ...
Set attributes by reading a generative model from IGoR marginal file. Sets attributes PVJ PdelV_given_V PdelJ_given_J PinsVJ and Rvj. Parameters ---------- marginals_file_name: str File name for a IGoR model marginals file.
def load_and_process_igor_model(self, marginals_file_name): """Set attributes by reading a generative model from IGoR marginal file. Sets attributes PVJ, PdelV_given_V, PdelJ_given_J, PinsVJ, and Rvj. Parameters ---------- marginals_file_name : str F...
Returns a new L { ImageBoundForwarderRefEntry } object.
def parse(readDataInstance): """ Returns a new L{ImageBoundForwarderRefEntry} object. @type readDataInstance: L{ReadData} @param readDataInstance: A L{ReadData} object with the corresponding data to generate a new L{ImageBoundForwarderRefEntry} object. @rtype: L...
Returns a L { ImageBoundForwarderRef } array where every element is a L { ImageBoundForwarderRefEntry } object.
def parse(readDataInstance, numberOfEntries): """ Returns a L{ImageBoundForwarderRef} array where every element is a L{ImageBoundForwarderRefEntry} object. @type readDataInstance: L{ReadData} @param readDataInstance: A L{ReadData} object with the corresponding data to generate ...
Returns a new L { ImageBoundImportDescriptor } object.
def parse(readDataInstance): """ Returns a new L{ImageBoundImportDescriptor} object. @type readDataInstance: L{ReadData} @param readDataInstance: A L{ReadData} object containing the data to create a new L{ImageBoundImportDescriptor} object. @rtype: L{ImageBoundI...