Skip to content

Instantly share code, notes, and snippets.

View J-Moravec's full-sized avatar

Jiří Moravec J-Moravec

View GitHub Profile
@J-Moravec
J-Moravec / turn_of_casting
Created June 5, 2020 00:48
Effect of reinvigoration on number of spell cast in battle
turn_of_casting = function(spell_fatigue, reinvigoration, turn_max=100){
tcast = c()
fatigue = 0
for(turn in seq_len(turn_max)){
if(fatigue < 100){
# cast spell
fatigue = fatigue + spell_fatigue
tcast = c(tcast, turn)
} else {
@J-Moravec
J-Moravec / OrdinalFailSample.xml
Last active April 27, 2021 01:03
An example of XML with randomly generated sequences and ordinal model with different number of states than in the data.
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<beast namespace="beast.core:beast.evolution.alignment:beast.evolution.tree.coalescent:beast.core.util:beast.evolution.nuc:beast.evolution.operators:beast.evolution.sitemodel:beast.evolution.substitutionmodel:beast.evolution.likelihood" required="" version="2.6">
<data id="test" dataType="standard">
<sequence taxon="A">0325001134145320315521441333450540150340142324031053552343434540345422555515404425225332030455334311</sequence>
<sequence taxon="B">3303111402245533434135501501430403113451242121243211312030250523440504251354554250554133235411202323</sequence>
<sequence taxon="C">0203545342141415331211042134245105533321245534032452154450211324241122021354024412103533542044452213</sequence>
<sequence taxon="D">5321401114230445532511142242040052431341215151200525030545523403103545524535302424314202314031013500</sequence>
<sequence taxon="E">00433510520542445013055315141311044142443015520443332013354310110010033533343440431233501314422223
@J-Moravec
J-Moravec / sra.r
Created May 24, 2021 23:58
Functions for downloading from SRA database according to GSM sample ID
#' sra.r
#'
#' Function for a programatical access to a SRA and GEO databases
#'
#' depends on rentrez, matrittr and xml packages
#' externally depends on sratools, all sratools must be available in path
import::here("magrittr", "%>%")
import::here("xml2", "read_xml", "as_list")
count_to = function(x = 5){
current = 0
function(){
if(i >= x)
return(NULL)
i <<- i+1
i
}
}