Skip to content

Instantly share code, notes, and snippets.

library(tidyverse)
#' Add arbitrary data to record from an infolist column
#'
#' Normal behaviour of RMassBank is that only specific columns from infolist.csv
#' are added to records. Any extra data is discarded.
#'
#' This function provides a possibility to add or overwrite data in a record
#' in a per-compound manner (as opposed to a global value specified in the
#' RMassBank settings). For example, the user may overwrite the retention time
@meowcat
meowcat / fixLumosMzXml.R
Created April 3, 2018 15:13
Fix incorrect precursor assignment in Lumos switching mode files converted to mzXML (ProteoWizard)
library(XML)
# dir <- "C:/Input_data/MassBank/20180219_Test"
# setwd(dir)
# fIn<- "01_4093_Flazasulfuron.mzXML"
#
# fixLumosMzXml <- function(f, prefix="fix_" out = paste0(dirname(f), prefix, basename(f)))
# {
# x <- xmlParse(f)
Name: methyl (2E)-2-(2-{[6-(2-cyanophenoxy)pyrimidin-4-yl]oxy}phenyl)-3-methoxyacrylate
Synon: Azoxystrobin
Synon: splash10-0z84000000-d532e80b217c51e4d7ec
Synon: $:99 InChI: InChI=1S/C22H17N3O5/c1-27-13-17(22(26)28-2)16-8-4-6-10-19(16)30-21-11-20(24-14-25-21)29-18-9-5-3-7-15(18)12-23/h3-11,13-14H,1-2H3/b17-13+
InChIKey: WFDXOXNFNRHQEC-UHFFFAOYSA-N
Notes: O=C(OC)\C(=C\OC)c3ccccc3Oc2ncnc(Oc1c(C#N)cccc1)c2
Formula: C22H17N3O5
Synon: $:99 CID: 86400
CAS#: 215934-32-0
Synon: $:99 CAS: 131860-33-8
@meowcat
meowcat / CopyCtorVersioned.R
Created January 7, 2016 15:38
Copy constructors while using the class Versioned of Biobase: bug
library(Biobase)
setClass("A",
representation = representation(var1="integer"),
prototype=prototype(var1=integer(),
new("Versioned", versions=c(A = "0.1.0"))),
contains="Versioned")
ia <- new("A")
server <- function(input, output, session) {
# Insert the right number of plot output objects into the web page
output$plots <- renderUI({
r.y <- lapply(1:input$panel.y, function(panels.y)
{
r.x <- lapply(1:input$panel.x, function(panels.x)
{
plotname <- paste("plot",panels.x,panels.y, sep="-")
clickname <- paste(plotname, "click", sep="-")
column(width= 12/input$panel.x, plotOutput(plotname, height=input$panel.h, width=input$panel.w,
@meowcat
meowcat / gist:befb649eb993b397bab3
Created November 17, 2014 13:20
Rcdk generates formulae from off-center mass?
library(rcdk)
limits <- list(
c("C", 0, 20),
c("H", 0, 24),
c("N", 0, 1),
c("O", 0,4))