This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import numpy.linalg as la | |
from readonly.PageRankFunctions import * | |
np.set_printoptions(suppress=True) | |
def pageRank(linkMatrix, d) : | |
n = linkMatrix.shape[0] | |
M = d * linkMatrix + (1-d)/n * np.ones([n, n]) # np.ones() is the J matrix, with ones for each entry. | |
r = 100 * np.ones(n) / n # Sets up this vector (n entries of 1/n × 100 each) | |
lastR = r |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# print(loadFile('./Downloads/Vibrio_cholerae.txt', 'CTTGATCAT')) | |
""" | |
FindClumps(Text, k, L, t) | |
Patterns ← an array of strings of length 0 | |
n ← |Text| | |
for every integer i between 0 and n − L | |
Window ← Text(i, L) | |
freqMap ← FrequencyTable(Window, k) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def indexOfPatternMatch (pattern, genome): | |
indexes = [] | |
patternLength = len(pattern) | |
for (index, _) in enumerate(genome): | |
if genome[index:(patternLength+index)] == pattern: | |
indexes.append(index) | |
return " ".join(str(item) for item in indexes) | |
def loadGenome(path, pattern): | |
file = open(path, 'r') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
testInput = 'AAAACCCGGT' | |
def getReverseComplement (DnaString): | |
allowedTypesMap = {'A': 'T', 'G': 'C', 'T':'A', 'C': 'G'} | |
result = [allowedTypesMap[char] for char in (DnaString)] | |
return ("".join(result))[::-1] | |
print(getReverseComplement(testInput)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
ALGORITHM: | |
PatternCount(Text, Pattern) | |
count ← 0 | |
for i ← 0 to |Text| − |Pattern| | |
if Text(i, |Pattern|) = Pattern | |
count ← count + 1 | |
return count | |
**/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { useLayoutEffect, useRef, MutableRefObject } from 'react'; | |
const useFlipAnimation = ( | |
elemRef: MutableRefObject<HTMLDivElement | null>, | |
layoutChangeFn: (x: boolean) => void, | |
whenToRun: boolean | |
) => { | |
const justMounted = useRef(true); | |
useLayoutEffect(() => { | |
if (justMounted.current) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const getDiff = (date1, date2) => { | |
let diff = date1 - date2 | |
const result = (diff/60) | |
return result; | |
} | |
const parseToSeconds = (time)=> { | |
const hrsMins = time.split(':') | |
const secHrs = parseInt(hrsMins[0],10) * 60 * 60 | |
const secMins = parseInt(hrsMins[1],10) * 60 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const removeInstance = (array=[], val=null) => { | |
if(!Array.isArray(array)) return 0; | |
if(!val) return array.length; | |
let currIndex = array.indexOf(val); | |
while(currIndex !== -1){ | |
array.splice(currIndex, 1) | |
currIndex = array.indexOf(val); | |
} | |
return array.length | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default function usePromise(api) { | |
const [state, dispatch] = useReducer( | |
(state, action) => { | |
switch (action.type) { | |
case 'LOADING': | |
return { ...state, loading: true } | |
case 'RESOLVED': | |
return { ...state, loading: false, response: action.response, error: null } | |
case 'ERROR': | |
return { ...state, loading: false, response: null, error: action.error } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def bitStr(n, s): | |
if n == 1: return s | |
return [ digit + bits for digit in bitStr(1,s) for bits in bitStr(n- 1,s)] | |
print (bitStr(3,'abc')) |
NewerOlder