Thursday, December 13, 2012

grails 1.3.8 and java 1.6

since we still have a lot of grails 1.3.8 application, we are forced to use them and apparently sometimes all the test fail with the following exception:


java.lang.IllegalAccessError: tried to access class org.apache.xml.serializer.XSLOutputAttributes from class org.apache.xalan.transformer.TransformerImpl at org.apache.xalan.transformer.TransformerImpl.executeChildTemplates(TransformerImpl.java:2387) at org.apache.xalan.transformer.TransformerImpl.executeChildTemplates(TransformerImpl.java:2255) at org.apache.xalan.lib.Redirect.write(Redirect.java:212) at org.apache.xalan.extensions.ExtensionHandlerJavaClass.processElement(ExtensionHandlerJavaClass.java:495) at org.apache.xalan.templates.ElemExtensionCall.execute(ElemExtensionCall.java:230) at org.apache.xalan.templates.ElemApplyTemplates.transformSelectedNodes(ElemApplyTemplates.java:395) at org.apache.xalan.templates.ElemApplyTemplates.execute(ElemApplyTemplates.java:177) at org.apache.xalan.transformer.TransformerImpl.executeChildTemplates(TransformerImpl.java:2336) at org.apache.xalan.transformer.TransformerImpl.applyTemplateToNode(TransformerImpl.java:2202) at org.apache.xalan.transformer.TransformerImpl.transformNode(TransformerImpl.java:1276) at org.apache.xalan.transformer.TransformerImpl.transform(TransformerImpl.java:673) at org.apache.xalan.transformer.TransformerImpl.transform(TransformerImpl.java:1192) at org.apache.xalan.transformer.TransformerImpl.transform(TransformerImpl.java:1170) at org.apache.tools.ant.taskdefs.optional.TraXLiaison.transform(TraXLiaison.java:187) at org.apache.tools.ant.taskdefs.XSLTProcess.process(XSLTProcess.java:709) at org.apache.tools.ant.taskdefs.XSLTProcess.execute(XSLTProcess.java:333) at org.apache.tools.ant.taskdefs.optional.junit.AggregateTransformer.transform(AggregateTransformer.java:264) at org.apache.tools.ant.taskdefs.optional.junit.XMLResultAggregator.execute(XMLResultAggregator.java:158) at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288) at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106) at _GrailsEvents_groovy$_run_closure5.doCall(_GrailsEvents_groovy:58) at _GrailsEvents_groovy$_run_closure5.call(_GrailsEvents_groovy) at _GrailsTest_groovy$_run_closure1.doCall(_GrailsTest_groovy:199) at TestApp$_run_closure1.doCall(TestApp:82) at gant.Gant$_dispatch_closure5.doCall(Gant.groovy:381) at gant.Gant$_dispatch_closure7.doCall(Gant.groovy:415) at gant.Gant$_dispatch_closure7.doCall(Gant.groovy) at gant.Gant.withBuildListeners(Gant.groovy:427) at gant.Gant.this$2$withBuildListeners(Gant.groovy) at gant.Gant$this$2$withBuildListeners.callCurrent(Unknown Source) at gant.Gant.dispatch(Gant.groovy:415) at gant.Gant.this$2$dispatch(Gant.groovy) at gant.Gant.invokeMethod(Gant.groovy) at gant.Gant.executeTargets(Gant.groovy:590)
fix in the BuildConfig.groovy file:


inherits("global") { // uncomment to disable ehcache // excludes 'ehcache' excludes 'serializer' }

git deleting remote branch

deleting a remote branch is rather clunky, but easy:

git push origin :branch

please ensure that you have the colon (:) infront of your branch name to ensure that the branch will deleted.

git memorizing branches


First, you must create your branch locally
git checkout -b your_branch
After that, you can work locally in your branch, when you are ready to share the branch, push it. The next command push the branch to the remote repository origin and tracks it
git push -u origin your_branch
Teammates can reach your branch, by doing:
git fetch
git checkout origin/your_branch
You can continue working in the branch and pushing whenever you want without passing arguments to git push (argumentless git push will push the master to remote master, your_branch local to remote your_branch, etc...)
git push
Teammates can push to your branch by doing commits and then push explicitly
... work ...
git commit
... work ...
git commit
git push origin HEAD:refs/heads/your_branch
Or tracking the branch to avoid the arguments to git push
git checkout --track -b your_branch origin/your_branch
... work ...
git commit
... work ...
git commit
git push
Found at stackoverflow

Wednesday, October 10, 2012

submitting all files in a directory to qsub

recently we needed a small script to submit all files in a directory to a script, executed by qsub.

#!/bin/bash if [ $# -lt 2 ]; then echo Missing arguments... echo "Use: process.sh 'input dir' 'output dir'" exit 1 fi if [ -d $1 ]; then for file in `ls $1` do qsub -cwd -p -512 run.sh $1$file $2 done else echo "Missing or incorrect input directory..." exit 1 fi

and the actual run.sh script is just a small java program, which takes our two parameters.

java -Xmx1024m -jar $HOME/data/jars/DataExtractor-0.1.jar $1 $2

Wednesday, October 3, 2012

maven-assembly-plugin - stackoverflow

currently I'm developing several helper tools for the alchemy project and promtply run into the issue of a stackoverflow exception with maven. Basically I try to assemble several archive, including all the required jars and generate the corresponding MANIFEST.MF files for a couple of main classes. apparently with maven3, you have to set the following flag: export MAVEN_OPTS=-Xss2m to avoid having a stackoverflow exception. Annoying... solution found here

Friday, September 21, 2012

Maven - generate executable jar file

Recently I started to work a bit more with scala again and also finally upgraded to my new nemesis, maven3. More torture than maven2, but I could not live without it.

So what I wanted todo is rather simple, build an archive containing all my classes, a generated manifest and make it executeable.

10 minutes later we found the solution:



<plugin> <artifactId>maven-assembly-plugin</artifactId> <executions> <execution> <id>convert-to-asci</id> <phase>package</phase> <goals> <goal>single</goal> </goals> <configuration> <archive> <manifest> <mainClass>edu.ucdavis.fiehnlab.alchemy.core.process.util.ConvertMZXmlToAscii</mainClass> <packageName>edu.ucdavis.fiehnlab.alchemy.core.process.util</packageName> <addClasspath>true</addClasspath> </manifest> </archive> <descriptors> <descriptor>src/main/descriptor/jar.xml</descriptor> </descriptors> <finalName>ConvertMzXmlToASCII-${project.version}</finalName> <appendAssemblyId>false</appendAssemblyId> </configuration> </execution> <execution> <id>alchemy-converter-zip</id> <phase>package</phase> <goals> <goal>single</goal> </goals> <configuration> <descriptors> <descriptor>src/main/descriptor/zip.xml</descriptor> </descriptors> <attach>true</attach> <finalName>alchemy-converter-${project.version}</finalName> </configuration> </execution> </executions> </plugin> The important part is to set the appendAssembyId to false, otherwise you get all kinds of annoying exceptions....

Thursday, August 23, 2012

relocating a git repository

Recently I started creating a new project, with the amazing name 'alchemy'. Sadly it turned out that this name was already taken on google code. So to start working on it I had to create a temporary project on google code and once I managed to get my greedy fingers on the others project name (successful I might add!) ...

...I had now the challenge to move my dozen or so lines of codes over to the new repository.

Now I'm the first one to admit, I'm still kinda green with 'git' and have only used it in the past on 1 or 2 little project and never on anything real. So how complicate will it be to move the code and not loose your complete history of commit (all 7 of them...)

Surprisingly easy it turns out, just issue the following magic commands and you are all set.

  1. git remote add alchemy https://code.google.com/p/alchemy/
  2. git push alchemy master
  3. git remote rm origin
  4. git remote add origin https://code.google.com/p/alchemy/
  5. git remote rm alchemy
Now looking at this, I'm quite sure I could had simplified this even more, but for now it got the job done.



Tuesday, June 26, 2012

VMWare and keyboards and mapping

currently I'm doing a lot of international traveling for our little company and to install BinBase systems at different locations in the world and keep running in the issue that my keyboard mapping is completely off.

For example denmark:

We have a danish server with a danish keyboard connected, which starts a vmware player instance. This instance has an english keyboard setup and an english keyboard layout. Now we are remotely connecting to this using a TeamViewer instance, with a US keyboard.
What is happening all the key maps are completely random and neither english or danish. The solution

in the configuration of the virtual machine, we need to explicitly set the hardware keyboard model to a danish model and the mapping to an english mapping to make it all work correctly using a remote session.

Monday, May 7, 2012

replacing space in filename under osx/linux

just a little handy script to replace all the spaces in a filename with an underscore


for file in *.txt do newname=$(echo $file | tr ' ' _) mv "$file" $newname done




just a little handy tool

where is my space?

so since 24h I try no to discover why my harddrive is full... All I did was deleting a VMWare image and now all my space is gone, which look like there were some error during the delete option...

for example:


sh-3.2# du -shcx /*
 11G /Applications
8.4G /Developer
5.7G /Library
  0B /Network
2.8G /System
4.0K /User Guides And Information
 28G /Users
4.0K /Volumes
4.1M /bin
  0B /cores
4.5K /dev
4.0K /etc
1.0K /home
  0B /lost+found
 15M /mach_kernel
1.0K /net
 49M /opt
8.6G /private
2.3M /sbin
4.0K /tmp
1.4G /usr
4.0K /var
 65G total


means that the system should have a total size of 65GB.

Now on the other hand,

sh-3.2# df -h

Filesystem      Size   Used  Avail Capacity  Mounted on

/dev/disk0s2   238Gi  181Gi   57Gi    77%    /
devfs          182Ki  182Ki    0Bi   100%    /dev
map -hosts       0Bi    0Bi    0Bi   100%    /net
map auto_home    0Bi    0Bi    0Bi   100%    /home



it says that 181GB are used, which is a difference of ca 120GB. Now where is this space?

Disabling the local backups in OSX, verifying the disk and rebooting using Command-R. I was able to reapair the disk, which cleaned up the space.


Filesystem      Size   Used  Avail Capacity  Mounted on
/dev/disk0s2   238Gi   68Gi  170Gi    29%    /
devfs          181Ki  181Ki    0Bi   100%    /dev
map -hosts       0Bi    0Bi    0Bi   100%    /net
map auto_home    0Bi    0Bi    0Bi   100%    /home

Thursday, May 3, 2012

Basic Rocks linux stuff.

Some basic Rocks Linux Cluster stuff... just some stuff I need to remember and always forget:

list all host interfaces:


rocks list host interface

changing the mac address of a network card: 


rocks set host interface mac HOSTNAME iface=eth1 mac=00:00:00:00:00:02



please be a aware that you also have to remove the mac address definition in the following file:


/etc/sysconfig/networking/devices/ifcfg-eth*


you should be able to just uncomment the mac address line, without any ill effects and this will simplify this process next time.


and possible in the dhcpd.conf file


vim /etc/dhcpd.conf


in case you modify the eth0 interface. To ensure that the dhcpd configuration still works as supposed to.





Wednesday, April 25, 2012

osx - set disk as startup disk via terminal

to set a disk as startup disk is quite simple just execute:


sudo bless -mount /Volumes/"name of your startup disk" -setBoot

BinBase - simulate the sifter algorithm directly on the database

currently I'm generating statistics for the BinBase system and so needed to simulate the annotation algorithm in sql.

It was rather simple....



-- 0.05 settings
select
count(*) as "count",
lower('0 < 0.05') as purity, lower('> 500') as signalNoise,
lower('> 800') as similarity

from spectra where purity > 0 and purity < 0.05 and signal_noise > 500 and match > 800

UNION

select
count(*) as "count",
lower('0 < 0.05') as purity, lower('> 50 && < 500') as signalNoise, lower('> 700') as similarity

from spectra where purity > 0 and purity < 0.05 and signal_noise > 50 and signal_noise <= 500 and match > 700


UNION

select
count(*) as "count",
lower('0 < 0.05') as purity, lower('> 5 && < 50') as signalNoise, lower('> 600') as similarity

from spectra where purity > 0 and purity < 0.05 and signal_noise > 5 and signal_noise <= 50 and match > 600

-- 0.3 settings

UNION

select
count(*) as "count",
lower('0 < 0.3') as purity, lower('> 500') as signalNoise,
lower('> 700') as similarity

from spectra where purity > 0 and purity < 0.3 and signal_noise > 500 and match > 700

UNION

select
count(*) as "count",
lower('0 < 0.3') as purity, lower('> 50 && < 500') as signalNoise, lower('> 600') as similarity

from spectra where purity > 0 and purity < 0.3 and signal_noise > 50 and signal_noise <= 500 and match > 600

UNION

select
count(*) as "count",
lower('0 < 0.3') as purity, lower('> 5 && < 50') as signalNoise, lower('> 500') as similarity

from spectra where purity > 0 and purity < 0.03 and signal_noise > 5 and signal_noise <= 50 and match > 500

-- all ither settings

UNION

select
count(*) as "count",
lower('> 0.3') as purity,
lower('> 500') as signalNoise,
lower('> 600') as similarity

from spectra where purity > 0.3 and signal_noise > 500 and match > 600

UNION

select
count(*) as "count",
lower('> 0.3') as purity,
lower('> 50 && < 500') as signalNoise, lower('> 500') as similarity

from spectra where purity > 0.3 and signal_noise > 50 and signal_noise <= 500 and match > 500

UNION

select
count(*) as "count",
lower('> 0.3') as purity,
lower('> 5 && < 50') as signalNoise, lower('> 450') as similarity

from spectra where purity > 0.03 and signal_noise > 5 and signal_noise <= 50 and match > 450

-- total --

union

select
count(*) as "count",
lower('no filter') as purity,
lower('no filter') as signalNoise,
lower('no filter') as similarity

from spectra



this are 3.25 settings btw

Tuesday, April 17, 2012

useful linux tools

getting ip address:

just needed a quick way to get the ip address of a certain network interface in a script. To dynamically update the bind address of a jboss application server.


ifconfig | grep eth2 -A 1 | grep inet | awk '{print $2}' | awk -F ':' '{print $2}'



gzipping all txt files in a directory with a lot of files, when the error:


-bash: /usr/local/fink/bin/gzip: Argument list too long


occurs.


find /Volumes/Thunderbolt\ SSD/data/ -name '*.txt' -exec gzip -vf {} \;

Tuesday, April 3, 2012

calculating mass spec similarity direct in postgres using stored procedures

since I'm currently debugging a rather annoying bug and for this reason need to be able to execute queries like:




CREATE OR REPLACE FUNCTION binbase.calculatesimilarity (in unknown text, in library text) RETURNS float8 AS
$BODY$

DECLARE
    result float8;
    sameIons int[];
    sameSpectraRelativeValuesunknown float8[];
    sameSpectraAbsoluteValuesunknown float8[];

    sameSpectraRelativeValueslibrary float8[];
    sameSpectraAbsoluteValueslibrary float8[];

    unknownSpectra float8[];
    unknownSpectraRel float8[];

    librarySpectra float8[];
    librarySpectraRel float8[];

    unknownSpectraLength int :=0;

    f1 float8 := 0;
    f2 float8 := 0;

    lib float8 := 0;
    unk float8 := 0;

    sqrt1 float8 := 0;
    summ float8 := 0;
    summ4 float8 := 0;
    summ2 float8 := 0;
    summ3 float8 := 0;

    array_len int;
    sameIon int;

BEGIN

    unknownSpectra = convertSpectra(unknown);
    unknownSpectraRel = createRelavieSpectra(unknownSpectra);

    librarySpectra = convertSpectra(library);
    librarySpectraRel = createRelavieSpectra(librarySpectra);

    array_len = 1000;

    sameIon = 0;

    for i in 1 .. array_len
    LOOP
        -- this will contain all the identical ions --
        IF unknownSpectra[i] is not null and librarySpectra[i] is not null
        then
            sameIons[sameIon] = i;
            sameSpectraRelativeValuesunknown[sameIon] = unknownSpectraRel[i];
            sameSpectraAbsoluteValuesunknown[sameIon] = unknownSpectra[i];
            sameSpectraRelativeValueslibrary[sameIon] = librarySpectraRel[i];
            sameSpectraAbsoluteValueslibrary[sameIon] = librarySpectra[i];
            sameIon = sameIon + 1;
        END IF;
       
    END LOOP;


    -- calculate f1 --
    for i in 1 .. sameIon
    LOOP
        -- this will contain all the identical ions --
        IF sameIons[i] is not null 
        then
            sqrt1 = sqrt(sameSpectraRelativeValueslibrary[i] * sameSpectraRelativeValuesunknown[i]);
            summ4 = summ4 + (sqrt1 * sameIons[i]);

            IF i >
            THEN
                unk = sameSpectraRelativeValuesunknown[i]/sameSpectraRelativeValuesunknown[i-1];
                lib = sameSpectraRelativeValueslibrary[i]/sameSpectraRelativeValueslibrary[i-1];

                if unk <= lib
                then
                    summ = summ + (unk/lib);
                else
                    summ = summ + (lib/unk);
                end if;
            END IF;
        END IF;
    END LOOP;

    unknownSpectraLength = 0;

    for i in 1 .. array_len
    LOOP
        IF librarySpectra[i] is not null and librarySpectra[i] > 0
        then
            summ2 = summ2 + (librarySpectraRel[i] * i);
        END IF;
       
        IF unknownSpectra[i] is not null and unknownSpectra[i] > 0
        then
            unknownSpectraLength = unknownSpectraLength + 1;
            summ3 = summ3 + (unknownSpectraRel[i] * i);
        END IF;
    END LOOP;

    f1 = summ4 / sqrt(summ2 * summ3);
    f2 = 1.0/sameIon * summ;

    result = (1000.0/(unknownSpectraLength + sameIon))*((unknownSpectraLength * f1) + (sameIon * f2));

    RETURN result;

EXCEPTION
    WHEN division_by_zero THEN
        RAISE NOTICE 'caught division_by_zero';
        RETURN 0;
END;
$BODY$
LANGUAGE 'plpgsql'




It's definitely not the fastest or most beautiful implementation I could think off. But it's quick enough for now.

It definitely makes the debugging of my algorithm easier and allows me to test new algorithms quicker.

converting an absolute massspec to a relative massspec using postgres stored functions

the next step to a working similarity calculation is to convert our absolute massspec to a relative spectra. Which is rather simple using stored procedures



-- calculates a relative spectra
create or replace function createRelavieSpectra(spectra float8[]) returns float8[] AS $$

DECLARE
result float8[1000];
array_len int;
maxValue float8 := 0;

BEGIN

array_len = array_upper(spectra,1);

for i in 1 .. array_len
LOOP
IF spectra[i] is not null and spectra[i] > maxValue
THEN
maxValue := spectra[i];
END IF;
END LOOP;

for i in 1 .. array_len
LOOP
if spectra[i] is not null
then
result[i] := spectra[i]/maxValue * 100;
end if;
END LOOP;

RETURN result;

END;
$$ LANGUAGE plpgsql;

converting massspecs to an array using postgres stored functions

currently I'm in the progress of writing a couple of stored procedures to query our BinBase database directly by spectral similarity and so the first step was to transform a standard leco spectra string to a standard double array, which represents a spectra.



-- converts a spectra string to a float array for further use --
create or replace function convertSpectra(spectra text) returns float8[] AS $$

DECLARE
result float8[1000];
spectraSplit text[];
ionSplit text[];
array_len int;

ion int;
value float8;

BEGIN

spectraSplit = regexp_split_to_array(spectra,' ');
array_len = array_upper(spectraSplit,1);

for i in 1 .. array_len
LOOP
ionSplit = regexp_split_to_array(spectraSplit[i],':');

ion := ionSplit[1];
value := ionSplit[2];


result[ion] = value;

END LOOP;

RETURN result;

END;
$$ LANGUAGE plpgsql;

Wednesday, February 22, 2012

testing all urls in a sitemap.xml file for existence with groovy

While working on some projects I figured out that it would be nice to have a quick and easy way to check all registered urls in a sitemap for existence and that groovy would be the perfect tool for this.

So we wrote a simple script for this


@Grab(group='org.codehaus.groovy.modules.http-builder', module='http-builder', version='0.5.0-RC2' )
import groovyx.net.http.HTTPBuilder

//small script to verify that an url exist, which was specified in a sitemap
//args[0] is the sitemap

//simple check
if(args.length != 1){
println "Usage\n"
println "please provide one argument, which is a filename pointing to your sitemap file"
println "\n"
return
}

//load file

def file = new File(args[0])

if(file.exists() == false){
println "\nsorry your file was not found. Missing file is ${args[0]}\n"
return
}

//parsing urls
def root = new XmlSlurper().parse(file)

def urls = root.url

println "\nchecking ${urls.size()} urls\n"

def success = 0
def failure = 0

urls.each{
def url = it.loc.text()

print "success:\t"

try {
new HTTPBuilder( url ).get( path:'' ) { response ->
response.statusLine.statusCode == 200

print "true"
success++
}
}
catch( e ) {
print "false"
failure++
}

print "\t that ${url} exists\n"
}

println "\nreport..."
println "\tsuccessful: ${success}"
println "\tfailed: ${failure}"
println "\ttotal: ${urls.size()}"

println "\nchecked ${urls.size()} urls in file ${args[0]}\n\n"



and the output looks something like this...


groovy verifyUrls.groovy Downloads/sitemap.xml

checking 45 urls

success: true that http://metacore-ucdavis.appspot.com/ exists
success: true that http://metacore-ucdavis.appspot.com/services exists
success: true that http://metacore-ucdavis.appspot.com/techno1 exists
success: true that http://metacore-ucdavis.appspot.com/techno2 exists
success: true that http://metacore-ucdavis.appspot.com/techno3 exists
success: true that http://metacore-ucdavis.appspot.com/setupx exists
success: true that http://metacore-ucdavis.appspot.com/projects exists
success: true that http://metacore-ucdavis.appspot.com/staff exists
success: true that http://metacore-ucdavis.appspot.com/login_form exists
success: true that http://metacore-ucdavis.appspot.com/join_form exists
success: true that http://metacore-ucdavis.appspot.com/mail_password_form exists
success: true that http://metacore-ucdavis.appspot.com/Members/admin exists
success: true that http://metacore-ucdavis.appspot.com/services/ exists
success: true that http://metacore-ucdavis.appspot.com/services/statistics exists
success: true that http://metacore-ucdavis.appspot.com/services/protocols exists
success: true that http://metacore-ucdavis.appspot.com/techno1/ exists
success: true that http://metacore-ucdavis.appspot.com/techno1/compounds exists
success: true that http://metacore-ucdavis.appspot.com/techno1/statistics exists
success: true that http://metacore-ucdavis.appspot.com/techno2/ exists
success: true that http://metacore-ucdavis.appspot.com/techno3/ exists
success: true that http://metacore-ucdavis.appspot.com/setupx/ exists
success: true that http://metacore-ucdavis.appspot.com/projects/ exists
success: true that http://metacore-ucdavis.appspot.com/staff/ exists
success: true that http://metacore-ucdavis.appspot.com/join_form?came_from= exists
success: true that http://metacore-ucdavis.appspot.com/index_html/view exists
success: true that http://metacore-ucdavis.appspot.com/Members/ exists
success: true that http://metacore-ucdavis.appspot.com/Members/admin/ exists
success: true that http://metacore-ucdavis.appspot.com/services/index_html/view exists
success: true that http://metacore-ucdavis.appspot.com/statistics/ exists
success: true that http://metacore-ucdavis.appspot.com/services/protocols/ exists
success: true that http://metacore-ucdavis.appspot.com/services/protocols/Metabolomics%20Vol.%201%2C%20No.%201%2C%20January%202005%20%28%202005%29.pdf exists
success: true that http://metacore-ucdavis.appspot.com/services/protocols/Proteomics%202004%2C%204%2C%2078-83.pdf exists
success: true that http://metacore-ucdavis.appspot.com/services/protocols/SulfurDeprivation.pdf exists
success: true that http://metacore-ucdavis.appspot.com/techno1/index_html/view exists
success: true that http://metacore-ucdavis.appspot.com/techno1/compounds/ exists
success: true that http://metacore-ucdavis.appspot.com/techno2/index_html/view exists
success: true that http://metacore-ucdavis.appspot.com/techno3/index_html/view exists
success: true that http://metacore-ucdavis.appspot.com/setupx/index_html/view exists
success: true that http://metacore-ucdavis.appspot.com/projects/index_html/view exists
success: true that http://metacore-ucdavis.appspot.com/staff/index_html/view exists
success: true that http://metacore-ucdavis.appspot.com/Members exists
success: true that http://metacore-ucdavis.appspot.com/Members/admin/index_html/view exists
success: true that http://metacore-ucdavis.appspot.com/statistics exists
success: true that http://metacore-ucdavis.appspot.com/statistics/index_html/view exists
success: true that http://metacore-ucdavis.appspot.com/techno1/compounds/index_html/view exists

report...
successful: 45
failed: 0
total: 45

checked 45 urls in file Downloads/sitemap.xml


Tuesday, February 7, 2012

java6 on ubuntu

just a quick tip I found how to use apt-get to install sun-java and not open-java.

sudo apt-get install python-software-properties
sudo add-apt-repository ppa:ferramroberto/java
sudo apt-get update
sudo apt-get install sun-java6-jdk sun-java6-plugin

You may want to also add the following

sudo update-alternatives --config java

You should get the following

Selection Path Priority Status
------------------------------------------------------------
* 0 /usr/lib/jvm/java-6-openjdk/jre/bin/java 1061 auto mode
1 /usr/lib/jvm/java-6-openjdk/jre/bin/java 1061 manual mode
2 /usr/lib/jvm/java-6-sun/jre/bin/java 63 manual mode

Press enter to keep the current choice[*], or type selection number: 2
Select (2) and press enter

Now running:

java -version
Returns:

java version "1.6.0_26"
Java(TM) SE Runtime Environment (build 1.6.0_26-b03)
Java HotSpot(TM) Server VM (build 20.1-b02, mixed mode)

Taken from:

http://superuser.com/questions/353983/how-do-i-install-the-sun-java-sdk-in-ubuntu-11-10-oneric

Monday, February 6, 2012

moving a virtual machine from VMWare Workstation/Fusion to vSphere

I'm currently in the process of moving several virtual machine from my home system (VMWare Workstation) and my work system (VMWare Fusion) to my new vSphere ESXI server and running into all kinds of issues.

First of all you can't run the converter on anything else than windows, which is rather annoying. Since I only got macs at work and no Windows machines, except for mine at home. Which has no access to the work network and I refuse to carry my 50lbs workstation around.

Translation: VMWare forces me to install a windows virtual machine to convert a virtual machine from vmx to vSPhere.

Yes I am slightly irritated about this lack of support for us apple fan boys (don't forget, linuxers have todo the same)

The next issue I encountered there doesn't seem to be a possibility to define Nat/Bridged and host only anymore. Instead I need to deal with custom vlans now or possible mixup some other DHCP services in the office.

For example my rocks linux cluster for testing binbase has 3 virtual network interfaces:

eth0 = host only (fixed IP address, fixed MAC)
eth1 = host only (fixed IP address, fixed MAC, for cluster nodes)
eth2 = bridge (dynamic ip address, random MAC, so that external hosts can easily access BinBase from the world and the image has internet access)

this is rather straight forward in VMware player/fusion/workstation.

Now for vSphere it looks rather different...

Basically you need to define networks for each interface and so my best idea was to simulate this so far.

To simulate the host only network:

a) create a new switch called 'host only' which is not connected to a network device.

To simulate the bridged network:

just use the default location and rename it to public to simplify life a bit.

and assign them in the vWware image to the different network interfaces.

etho0 = host only
eth1 = host only
eth2 = public

now the big question is, if I created another virtual machine, in the same ip range as my host only network is defined, can it talk to the other machines? I think I shall test this with a virtual compute node and report back. Maybe to be on the save site, I just create a second host only network?

Friday, February 3, 2012

integration testing with the grails export plugin

currently I'm testing a lot of controllers in my miniX application and run into the issue that it's nearly impossible to test the grails export plugin. Since the setup tends to get more complicated than your actual test.

Obviously I could redesign my controllers and make them more transparent. But this is not the point right now.

So lets look at our controller:



/**
* should be a service and not a method in the controller, bad design from me. -5 points
*/
def exportStudies(def studies, def response, String format, String extension, String filename) {

//title of the file
def parameters = [title: "Study Design"]

//required labels and mappings
def label = [
"classId": "Class Id",
"comment": "Comment",
"fileName": "Filename",
"label": "Label",
"organName": "Organ",
"speciesName": "Species",
"treatment": "Treatment"
]

//required fields
def fields = [
"classId",
"comment",
"fileName",
"label",
"organName",
"speciesName",
"treatment"
]
//contains out data for the save
def data = []

studies.each {Studie studie ->

//fill our object with data
studie.classes.each {BaseClass clazz ->
if (clazz instanceof ExperimentClass) {
clazz.samples.each {Sample sample ->

StudieExportObject exportObject = new StudieExportObject()

exportObject.classId = clazz.id
exportObject.speciesName = clazz.species.name
exportObject.organName = clazz.organ.name
exportObject.treatment = clazz.treatmentSpecific.toParentString()
exportObject.fileName = "${sample.fileName}_${sample.fileVersion}"
exportObject.comment = sample.comment
exportObject.label = sample.label

data.add(exportObject)

}
}
}
}

//set the extension to xls
response.setHeader("Content-disposition", "attachment; filename=${filename}.${extension}")

//calling the export service, which is really uggly implemented
exportService.export(format, response.outputStream, data, fields, label, [:], parameters)

}

/**
* export the studie as xls file
*/
def exportStudieToXLS = {

Studie studie = Studie.get(params.id)

if (studie == null) {
flash.message = "sorry this object wasn't found!"
redirect(action: "list", controller: "studie")
}
else if (!studie.canAccess()) {
flash.message = "sorry you do not have the permission to access this object!"
redirect(action: "list", controller: "studie")
}
else {

//run the export
exportStudies([studie], response, "excel", "xls", studie.id.toString())
}
}



after spending some time with the attempt to setup the export service correctly, I just scrapped this approach and figured. I assume it works and it's well tested. So lets rather test our logic and make sure it works. Hence we just mock the service in our test.


void testExportStudies() {


Studie studie = AquisitionTableServiceTests.generateNamedStudie(20, false)

GCTof tof = GCTof.list()[0]

AquisitionTableService service = new AquisitionTableService()
GenerateFileNameService generateFileNameService = new GenerateFileNameService()
generateFileNameService.modifyClassService = new ModifyClassService()

generateFileNameService.addCalibrationSamples(studie, tof, new Date(), ShiroUser.list()[0])
generateFileNameService.addReactionBlankSamples(studie, tof, new Date(), ShiroUser.list()[0])
generateFileNameService.addQualityControlSamples(studie, tof, new Date(), ShiroUser.list()[0])


ExportStudieController controller = new ExportStudieController()

//mocking the export service, since the developer of it did a really shitty job to ensure it can be easily tested, FAIL
controller.exportService = [
export : { def a, def b, def c, def d, def e,def f, def g ->
assertTrue(a instanceof String)
assertTrue(b instanceof OutputStream)
assertTrue(c instanceof Collection)
assertTrue(d instanceof Collection)
assertTrue(e instanceof Map)
assertTrue(f instanceof Map)
assertTrue(g instanceof Map)

//some cool testing logic gets here...
}
] as ExportService

controller.metaDataService = new MetaDataService()

controller.exportStudies([studie], controller.response, "csv", "txt", "test")
}

Wednesday, February 1, 2012

installing vmware server on ubuntu 11.10

so I'm trying to install a ubuntu base vmware image hosting platform right now keep running into issues.

done on a system with the following kernel config:

Linux sun 3.0.0-15-server #26-Ubuntu SMP Fri Jan 20 19:07:39 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux

first you need to link some files to make the script start generating the modules...

$ sudo ln -s /lib/modules/your_kernel_version/build/include/generated/utsrelease.h /lib/modules/your_kernel_version/build/include/linux/utsrelease.h
$ sudo ln -s /lib/modules/your_kernel_version/build/include/generated/autoconf.h /lib/modules/your_kernel_version/build/include/linux/autoconf.h

which now makes the installation fail with some error of missing smp.h header files

/tmp/vmware-root/modules/vmmon-only/linux/driver.c:40: fatal error: linux/smp_lock.h: No such file or directory
compilation terminated.

next step was to downgrade the kernel to the last version where I found enough info about it to make it compile with vmware.

Linking the files again

ln -s /lib/modules/2.6.38-10-server/build/include/generated/utsrelease.h /lib/modules/2.6.38-10-server/build/include/linux/utsrelease.h
ln -s /lib/modules/2.6.38-10-server/build/include/generated/autoconf.h /lib/modules/2.6.38-10-server/build/include/linux/autoconf.h

and now it fails with the following error

/tmp/vmware-config0/vmmon-only/linux/driver.c:1423:4: error: too many arguments to function ‘smp_call_function’
include/linux/smp.h:73:5: note: declared here
/tmp/vmware-config0/vmmon-only/linux/driver.c: In function ‘LinuxDriver_Ioctl’:
/tmp/vmware-config0/vmmon-only/linux/driver.c:1987:18: error: ‘struct task_struct’ has no member named ‘euid’
/tmp/vmware-config0/vmmon-only/linux/driver.c:1987:35: error: ‘struct task_struct’ has no member named ‘uid’
/tmp/vmware-config0/vmmon-only/linux/driver.c:1988:11: error: ‘struct task_struct’ has no member named ‘fsuid’
/tmp/vmware-config0/vmmon-only/linux/driver.c:1988:29: error: ‘struct task_struct’ has no member named ‘uid’
/tmp/vmware-config0/vmmon-only/linux/driver.c:1989:18: error: ‘struct task_struct’ has no member named ‘egid’
/tmp/vmware-config0/vmmon-only/linux/driver.c:1989:35: error: ‘struct task_struct’ has no member named ‘gid’
/tmp/vmware-config0/vmmon-only/linux/driver.c:1990:11: error: ‘struct task_struct’ has no member named ‘fsgid’
/tmp/vmware-config0/vmmon-only/linux/driver.c:1990:29: error: ‘struct task_struct’ has no member named ‘gid’
/tmp/vmware-config0/vmmon-only/linux/driver.c:2007:7: error: too many arguments to function ‘smp_call_function’
include/linux/smp.h:73:5: note: declared here
make[2]: *** [/tmp/vmware-config0/vmmon-only/linux/driver.o] Error 1
make[1]: *** [_module_/tmp/vmware-config0/vmmon-only] Error 2
make[1]: Leaving directory `/usr/src/linux-headers-2.6.38-10-server'

getting frustrated I went back to a bit more car research. Still at the point of 335i vs Cayman vs Boxster vs Z4. It all depends on the european delivery of if I can find a nice 1-2 year old cpo'ed car in my area.

calmed down a lot and so the next step was to rename my vmware server archive to the right extension:

mv VMware-server-2.0.2-203138.x86_64.gz VMware-server-2.0.2-203138.x86_64.tar.gz

and following the instructions here

and it worked


Starting VMware services:
Virtual machine monitor done
Virtual machine communication interface done
VM communication interface socket family: done
Virtual ethernet done
Bridged networking on /dev/vmnet0 done
Host-only networking on /dev/vmnet1 (background) done
DHCP server on /dev/vmnet1 done
Host-only networking on /dev/vmnet8 (background) done
DHCP server on /dev/vmnet8 done
NAT service on /dev/vmnet8 done
VMware Server Authentication Daemon (background) done
Shared Memory Available done
Starting VMware management services:
VMware Server Host Agent (background) done
VMware Virtual Infrastructure Web Access
Starting VMware autostart virtual machines:
Virtual machines done

The configuration of VMware Server 2.0.2 build-203138 for Linux for this
running kernel completed successfully.

Housekeeping...
Thank you for using the script!
Patch provided by:
Ramon de Carvalho Valle
http://risesecurity.org
updated by sirusdv (http://ubuntuforums.org/member.php?u=1289848)
Script author:
Radu Cotescu
http://radu.cotescu.com

now I just need to convince grub to use the 'old' kernel by default...

Thursday, January 26, 2012

grails plugins and feedback

once in a while I get emails like this, which makes me really happy to put effort into open source projects.

Hi Gert,

I'm fairly new to Grails and Java and I've been using your Grails jprogress plugin the past few days and it works great - thanks.

I wanted to update the message text as a process went along but didn't see that featured defined in the service. I assumed that you were using the jProgressBar java class and that I could define it's setString method but as I look around I don't think that's the case. Is there a way to do that with your plugin?

Thanks,

Greg

obviously it also means I need todo some more stuff to keep people happy, hence even less spare time for other stuff :(