Posts

App with fastapi, Arangodb and Graphql

Image
Configuring fastapi, arangodb and graphql with authentication: It uses fastapi graphene, graphene-pydantic, python-arango and fastapi-jwt-auth mkdir fastapi_learn_project cd fastapi_learn_project virtualenv -p python3 env source env/bin/activate pip3 install fastapi uvicorn graphene graphene-pydantic==0.1.0 python-arango fastapi-jwt-auth Setup database database.py 1 2 3 4 5 6 7 from arango import ArangoClient # Initialize the ArangoDB client. client = ArangoClient(hosts= 'http://localhost:8529' ) # Connect to "test" database as root user. db = client.db( 'fastapidemo' , username= 'root' , password= '****' ) You can find how to set up arangodb at: serializers.py 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 from typing import List, Optional from graphene_pydantic import PydanticInputObjectType, PydanticObjectType from pydantic import BaseModel class UserModel (BaseModel): _id: str name...

Generating UUID4 from custom random number generator (RNG) using rust

First you need to generate random seed: It can be from any RNG generator, for example in near protocol sdk,  https://docs.rs/near-sdk/0.11.0/near_sdk/env/fn.random_seed.html pub fn random_seed() -> Vec<u8> use rand::Rng; fn main () { let mut rng = rand::thread_rng(); let mut randvec: Vec < u8 > = Vec ::new(); let mut counter = 0 ; let result = loop { counter += 1 ; let n1: u8 = rng.gen(); randvec.push(n1); if counter == 32 { break randvec; } }; println! ( "{:?}" , result); } Its generate vector, but you need an array to feed into from_seed function. This is the complete code. use rand::{rngs::StdRng, RngCore, SeedableRng, Rng}; use uuid::{Builder, Variant, Version}; fn main () { let mut rng = rand::thread_rng(); let mut randvec: Vec < u8 > = Vec ::new(); let mut counter = 0 ; let result_vec = loop { counter ...

Auto Cross covariance Python

Auto Cross Covariance for converting protein sequence descriptor to single length vector import numpy as np # z1 z2 and z3 descriptor was used to represent the protein sequence # Index j was used for the z-scales (j = 1, 2, 3), # n is the number of amino acids in a sequence, # index i is the amino acid position (i = 1, 2, ...n) # l is the lag (l = 1, 2, ...L). # a short range of lags (L= 1, 2, 3, 4, 5) Z = np.random.rand(3,80) print(Z) #Z = np.array([[1,2,3,4],[5,6,7,8],[9,10,11,12]]) n = Z.shape[1] n = n-1 print(n) # Autocovariance column = [] for j in range(0,3): row = [] for l in range(0,5): summ = 0 for i in range(0,n-l): rightsum = (Z[j,i]*Z[j,i+1])/(n-l) summ = summ + rightsum row.append(summ) column.append(row) R = np.array(column) print(R) # Cross Covariance ja = [0,1,2,0,1,2] ka = [1,0,0,2,2,1] column = [] for j,k in zip(ja,ka): row = [] for l in range(0,5): summ = 0 for i in range...

Parker Method for Prediction of surface sites

Image
Parker et al. has produced following hydrophilicity scale derived from High-Performance Liquid Chromatography (HPLC) Peptide Retention Data. Surface Profile: The surface profile for a protein was determined by summing the parameters for each residue of seven-residue segment and assigning this sum to the fourth residue. This procedure was repeated by shifting the segment by one residue from the N-to the C-terminus. A plot of these values against the residue number using either HPLC, accessiblity, bulk hydrophobic character, hydrophobicity, global, pi, or hydropathy parameters (Here only HPLC is used) provided a surface profile. To objectively interpret all of these profiles, Parker et al. has used following arbitary of rules: 1)  The average surface hydrophilicity is defined as the the mean of the profile values for a protein using a particular parameter set. 2) Any residue with a profile value greater than 25% above the average surface hydrophilicity value were defined a...