Skip to content

Instantly share code, notes, and snippets.

Darya Vanichkina dvanic

Block or report user

Report or block dvanic

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View pythonGetObjectMethod.py
def get_methods(object, spacing=20):
methodList = []
for method_name in dir(object):
try:
if callable(getattr(object, method_name)):
methodList.append(str(method_name))
except:
methodList.append(str(method_name))
processFunc = (lambda s: ' '.join(s.split())) or (lambda s: s)
for method in methodList:
@dvanic
dvanic / RtabulateNAsbyColumn
Created Oct 1, 2019
Tabulate NAs by column in R using dplyr
View RtabulateNAsbyColumn
transaction1 %>%
select_if(function(x) any(is.na(x))) %>%
summarise_each(~sum(is.na(.))) %>%
t()
View FilesByDate.sh
# https://stackoverflow.com/questions/158044/how-to-use-find-to-search-for-files-created-on-a-specific-date
# files created on June 7th
find . -type f -newermt 2007-06-07 ! -newermt 2007-06-08
View challenges.R
# This is the file for the challenges
# 01 Raster structure --------
## Challenge 1
# Challenge: What units are our data in?
#
#
## Challenge 2
# Challenge: Use the output from the GDALinfo() function to find out what NoDataValue is used for our DSM_HARV dataset.
#
#
View testexistence.R
for (object in characterlistofobjectnames) {
if (exists(object) == FALSE) {
stop(paste0(paste0("The object ", object), " does not exist! Please edit your input list before continuing."))
}
}
@dvanic
dvanic / AwkOneLiners.sh
Last active Aug 20, 2016
OneLinersFromMyArchiveawk
View AwkOneLiners.sh
# http://www.student.northpark.edu/pemente/awk/awk1line.txt
# FILE SPACING:
# double space a file
awk '1;{print ""}'
awk 'BEGIN{ORS="\n\n"};1'
# double space a file which already has blank lines in it. Output file
# should contain no more than one blank line between lines of text.
@dvanic
dvanic / AwkOneLiners.sh
Created Aug 20, 2016
OneLinersFromMyArchiveawk
View AwkOneLiners.sh
# http://www.student.northpark.edu/pemente/awk/awk1line.txt
# FILE SPACING:
# double space a file
awk '1;{print ""}'
awk 'BEGIN{ORS="\n\n"};1'
# double space a file which already has blank lines in it. Output file
# should contain no more than one blank line between lines of text.
View useful_pandas_snippets.py
#List unique values in a DataFrame column
pd.unique(df.column_name.ravel())
#Convert Series datatype to numeric, getting rid of any non-numeric values
df['col'] = df['col'].astype(str).convert_objects(convert_numeric=True)
#Grab DataFrame rows where column has certain values
valuelist = ['value1', 'value2', 'value3']
df = df[df.column.isin(valuelist)]
@dvanic
dvanic / readGTF.py
Last active Aug 15, 2016
pythonReadGTFlocal
View readGTF.py
from collections import defaultdict
import gzip
import pandas as pd
import re
GTF_HEADER = ['seqname', 'source', 'feature', 'start', 'end', 'score',
'strand', 'frame']
R_SEMICOLON = re.compile(r'\s*;\s*')
R_COMMA = re.compile(r'\s*,\s*')
@dvanic
dvanic / cigarfunction.r
Created Jul 29, 2016
R gist to summarise CIGAR string
View cigarfunction.r
matcher <- function(pattern, x) {
ind = gregexpr(pattern, x)[[1]]
start = as.numeric(ind)
end = start + attr(ind, "match.length")- 2
apply(cbind(start,end), 1, function(y) substr(x, start=y[1], stop=y[2]));
}
doone <- function(c, cigar) {
pat <- paste("\\d+", c , sep="")
sum(as.numeric(matcher(pat, cigar)), na.rm=T)
You can’t perform that action at this time.