08 May 2007

Hello World ! My first FLEX2 Application.

Adobe Flex 2 software is a rich Internet application framework based on Adobe Flash that will enable you to productively create beautiful, scalable applications that can reach virtually anyone on any platform.

The SDK was downloaded and extracted from : http://download.macromedia.com/pub/flex/sdk/flex_sdk_2.zip.

File:first.mxml

<?xml version="1.0" encoding="utf-8"?>
<mx:Application
xmlns:mx="http://www.adobe.com/2006/mxml"
horizontalAlign="center" verticalAlign="center">
<mx:Button id="myButton" label="Hello Bioinformatics World !" />
</mx:Application>


The file was compiled to flash using the mxmlc command (a java application):
>FLEX/SDK/bin/mxmlc --strict=true --file-specs first.mxml
Loading configuration file FLEX/SDK/frameworks/flex-config.xml
FLEX/test/first.swf (125402 bytes)
> ls
first.mxml first.swf


I then opened first.swf in firefox and...
My First FLEX2 app

Whaaaa ! It worked without any problem !!

I'M THE KING OF THE WORLD !!


This looks exciting ! I need a good tutorial ! I need a good tutorial ! I need ....


Pierre :-)

06 May 2007

04 May 2007

Hello World in MQL/ Freebase.

OK, here are my very first tests in freebase.
The MQL query language is used to send the query to the server. It is based on the JSON format.

The following MQL query asks for the date/place of birth, the gender, for all the biologists in freebase.


{
"query":[{
"/people/person/date_of_birth":null,
"/people/person/gender":null,
"/people/person/place_of_birth":null,
"/people/person/profession":"biologist",
"name":null
}]
}


This query can be copied in the freebase query editor (http://www.freebase.com/view/queryeditor/) or can be send via http (see below my example in java).

Here is the result formated in JSON as it appears in the editor:


{
"q1": {
"status": "/mql/status/ok",
"result": [
{
"/people/person/date_of_birth": "1809-12-02",
"/people/person/profession": "Biologist",
"/people/person/gender": "Male",
"name": "Charles Darwin",
"/people/person/place_of_birth": "Shrewsbury"
},
{
"/people/person/date_of_birth": "1859",
"/people/person/profession": "Biologist",
"/people/person/gender": "Male",
"name": "Jacques Loeb",
"/people/person/place_of_birth": null
}
]
},
"status": "200 OK"
}


Only two records ! :-) because as far as I could see, Freebase was automatically generated from wikipedia (name, description ...) whereas most fields (gender, date of birth etc...) remain empty and are waiting for the users to be filled.

Iv' also tried to send this query via JAVA.


import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.net.URLConnection;
import java.net.URLEncoder;





public class Test01 {
static final String BASE_URL="http://www.freebase.com";
static final String MQLREADURL=BASE_URL+"/api/service/mqlread";


void query(String json) throws IOException
{
String envelope = "{\"qname\":{\"query\":" +json+ "}}";
String urlStr =MQLREADURL+"?queries="+URLEncoder.encode(envelope, "UTF-8");

// Now place the query in JSON envelope objects, and URL encode the envelopes
URL url= new URL(urlStr);
URLConnection con=url.openConnection();
//set the cookie
con.setRequestProperty("Cookie","metaweb-user="+###YOUR_COOKIE_VALUE###);
con.connect();
InputStream in=con.getInputStream();
int c;
//echo the result to stdout
while((c=in.read())!=-1) System.out.write(c);
in.close();
}


public static void main(String[] args)
{
try {
Test01 t= new Test01();
t.query("[{ \"/people/person/date_of_birth\":null, \"/people/person/gender\":null, \"/people/person/place_of_birth\":null, \"/people/person/profession\":\"biologist\", \"name\":null }] ");

} catch (Exception e) {
e.printStackTrace();
}
}

}


This source uses a URLConnection object to send the query. You may notice that the value of a cookie called metaweb-user must be provided. This cookie identifies your account on freebase and its value can be found in the "preferences panel: Privacy" in firefox.

Pierre.

(Trying to use) The NCBI ASN.1 library

Motivation: I was looking for a way to store and to read my linkage data using a binary format, (then I could get a faster and a smaller size).

I had a glance to the NCBI C toolbox which uses ASN.1 as its main format to encode and to structure the data just like XML.

About ASN1: ASN.1 is a standard that describes data structures for representing, encoding, transmitting, and decoding data. It provides a set of formal rules for describing the structure of objects that are independent of machine-specific encoding techniques and is a precise, formal notation that removes ambiguities. Its usage can be compared to the more recent XML Schema (see also my previous post about JAXB).

The NCBI ASN1 C library is descibed here: http://www.ncbi.nlm.nih.gov/IEB/ToolBox/SDKDOCS/ASNLIB.HTML

Although I still have a problem in the last part, this post can be considered as my first experience with the ASN.1 library.

I started my test by defining a small ASN.1 module to store some PCR primers and their hits on the genome


PCRMod DEFINITIONS ::=
BEGIN
Orientation ::= ENUMERATED
{
forward(0),
reverse(1)
}

Hit ::= SEQUENCE
{
chromosome VisibleString, -- chromosome
start INTEGER, -- starting position in chromosome 5' + strand
orient Orientation -- orientation
}

Primer ::= SEQUENCE {
name VisibleString, -- name
tm REAL OPTIONAL, -- melting temperature
sequence VisibleString, -- sequence
hits SET OF Hit OPTIONAL -- hits
}

PrimerInput ::=SEQUENCE OF Primer

END


This schema 'primer.asn' was digested by the asntool


asntool -Z T -w 128 -m primer.asn -G T -B primer -K primerasn
asntool -Z T -w 128 -m primer.asn-o primerasn.h


here asntool will read the 'primer.asn' and will generate three source files:

primerasn.h: is a C header containing all states that will be used the parse the ASN1 files.
/***********************************************************************
*
**
* Automatic header module from ASNTOOL
*
************************************************************************/

(...)

static char * asnfilename = "primerasn.h";
static AsnValxNode avnx[2] = {
{20,"forward" ,0,0.0,&avnx[1] } ,
{20,"reverse" ,1,0.0,NULL } };

static AsnType atx[20] = {
{401, "Orientation" ,1,0,0,0,0,0,0,0,NULL,&atx[1],&avnx[0],0,&atx[2]} ,
{310, "ENUMERATED" ,0,10,0,0,0,0,0,0,NULL,NULL,NULL,0,NULL} ,
{402, "Hit" ,1,0,0,0,0,0,0,0,NULL,&atx[8],&atx[3],0,&atx[9]} ,
{0, "chromosome" ,128,0,0,0,0,0,0,0,NULL,&atx[4],NULL,0,&atx[5]} ,
{323, "VisibleString" ,0,26,0,0,0,0,0,0,NULL,NULL,NULL,0,NULL} ,
{0, "start" ,128,1,0,0,0,0,0,0,NULL,&atx[6],NULL,0,&atx[7]} ,
{302, "INTEGER" ,0,2,0,0,0,0,0,0,NULL,NULL,NULL,0,NULL} ,
{0, "orient" ,128,2,0,0,0,0,0,0,NULL,&atx[0],NULL,0,NULL} ,
{311, "SEQUENCE" ,0,16,0,0,0,0,0,0,NULL,NULL,NULL,0,NULL} ,
{403, "Primer" ,1,0,0,0,0,0,0,0,NULL,&atx[8],&atx[10],0,&atx[17]} ,
{0, "name" ,128,0,0,0,0,0,0,0,NULL,&atx[4],NULL,0,&atx[11]} ,
{0, "tm" ,128,1,0,1,0,0,0,0,NULL,&atx[12],NULL,0,&atx[13]} ,
{309, "REAL" ,0,9,0,0,0,0,0,0,NULL,NULL,NULL,0,NULL} ,
{0, "sequence" ,128,2,0,0,0,0,0,0,NULL,&atx[4],NULL,0,&atx[14]} ,
{0, "hits" ,128,3,0,1,0,0,0,0,NULL,&atx[16],&atx[15],0,NULL} ,
{0, NULL,1,-1,0,0,0,0,0,0,NULL,&atx[2],NULL,0,NULL} ,
{314, "SET OF" ,0,17,0,0,0,0,0,0,NULL,NULL,NULL,0,NULL} ,
{404, "PrimerInput" ,1,0,0,0,0,0,0,0,NULL,&atx[19],&atx[18],0,NULL} ,
{0, NULL,1,-1,0,0,0,0,0,0,NULL,&atx[9],NULL,0,NULL} ,
{312, "SEQUENCE OF" ,0,16,0,0,0,0,0,0,NULL,NULL,NULL,0,NULL} };

static AsnModule ampx[1] = {
{ "PCRMod" , "primerasn.h",&atx[0],NULL,NULL,0,0} };

static AsnValxNodePtr avn = avnx;
static AsnTypePtr at = atx;
static AsnModulePtr amp = ampx;



/**************************************************
*
* Defines for Module PCRMod
*
**************************************************/

#define ORIENTATION &at[0]

#define HIT &at[2]
#define HIT_chromosome &at[3]
#define HIT_start &at[5]
#define HIT_orient &at[7]

#define PRIMER &at[9]
#define PRIMER_name &at[10]
#define PRIMER_tm &at[11]
#define PRIMER_sequence &at[13]
#define PRIMER_hits &at[14]
#define PRIMER_hits_E &at[15]

#define PRIMERINPUT &at[17]
#define PRIMERINPUT_E &at[18]




primer.h: contains the C headers used to parse the structure declared in the ASN1 schema. There is a method to allocate/free/read and write each structure.
#
(...)
/**************************************************
*
* Generated objects for Module PCRMod
*
**************************************************/

NLM_EXTERN Boolean LIBCALL
primerAsnLoad PROTO((void));
/* following #defines are for enumerated type, not used by object loaders */
#define Orientation_forward 0
#define Orientation_reverse 1



/**************************************************
* Hit
**************************************************/
typedef struct struct_Hit {
struct struct_Hit PNTR next;
Uint4 OBbits__;
CharPtr chromosome;
Int4 start;
Uint2 orient;
} Hit, PNTR HitPtr;


NLM_EXTERN HitPtr LIBCALL HitFree PROTO ((HitPtr ));
NLM_EXTERN HitPtr LIBCALL HitNew PROTO (( void ));
NLM_EXTERN HitPtr LIBCALL HitAsnRead PROTO (( AsnIoPtr, AsnTypePtr));
NLM_EXTERN Boolean LIBCALL HitAsnWrite PROTO (( HitPtr , AsnIoPtr, AsnTypePtr));



/**************************************************
* Primer
**************************************************/
typedef struct struct_Primer {
struct struct_Primer PNTR next;
Uint4 OBbits__;
CharPtr name;
#define OB__Primer_tm 0

FloatHi tm;
CharPtr sequence;
struct struct_Hit PNTR hits;
} Primer, PNTR PrimerPtr;


NLM_EXTERN PrimerPtr LIBCALL PrimerFree PROTO ((PrimerPtr ));
NLM_EXTERN PrimerPtr LIBCALL PrimerNew PROTO (( void ));
NLM_EXTERN PrimerPtr LIBCALL PrimerAsnRead PROTO (( AsnIoPtr, AsnTypePtr));
NLM_EXTERN Boolean LIBCALL PrimerAsnWrite PROTO (( PrimerPtr , AsnIoPtr, AsnTypePtr));



/**************************************************
* PrimerInput
**************************************************/
typedef struct struct_Primer PrimerInput;
typedef struct struct_Primer PNTR PrimerInputPtr;
#define PrimerInputNew() PrimerNew()



NLM_EXTERN PrimerInputPtr LIBCALL PrimerInputFree PROTO ((PrimerInputPtr ));
NLM_EXTERN PrimerInputPtr LIBCALL PrimerInputNew PROTO (( void ));
NLM_EXTERN PrimerInputPtr LIBCALL PrimerInputAsnRead PROTO (( AsnIoPtr, AsnTypePtr));
NLM_EXTERN Boolean LIBCALL PrimerInputAsnWrite PROTO (( PrimerInputPtr , AsnIoPtr, AsnTypePtr));
(...)


and primer.c the C implementation of those methods.

(...)


OK, here comes the problem: I wrote a simple ASN1 input
PrimerInput::={
{
name "Primer0",
sequence "ATAGCTACTGATGCATGCATCG"
}
}


and I wanted to read each primer. Here is my source:
#include <cerrno>
#include <fstream>
#include <iostream>
#include <string>
#include <stdexcept>
#include <asn.h>
#include <cassert>

/** include the files generated by the ASN1 tool */
#include <primer.h>
#include <primerasn.h>

int main(int argc, char** argv)
{
int optind=1;

/* init my specification */
if(!primerAsnLoad())
{
fprintf(stderr,"#%s: cannot load ASN1 specification \"%s\".\n" ,
argv[0],asnfilename );
return (EXIT_FAILURE);
}

if(optind+1!=argc)
{
fprintf(stderr,"bad input : usage %s ASN1 file\n",argv[0]);
return(EXIT_FAILURE);
}

/** open the input file */
AsnIoPtr in = AsnIoOpen(argv[1],"r");
if(in==NULL)
{
fprintf(stderr,"Cannot Read %s\n",argv[1]);
return(EXIT_FAILURE);
}


/** init the state of the parser */
AsnTypePtr asn_type_ptr=PRIMERINPUT;
PrimerPtr primer= NULL;

/** while we can read a primer... */
while ((asn_type_ptr = AsnReadId(in, amp, asn_type_ptr)) != NULL)
{
if(asn_type_ptr==PRIMERINPUT_E)
{
primer= PrimerAsnRead(in,asn_type_ptr);
if(primer!=NULL)
{
fprintf(stderr,"sequence: %s\n",primer->sequence);
PrimerFree(primer);
}
}
else
{
AsnReadVal(in, asn_type_ptr,NULL);
}
}

AsnIoClose(in);
return(0);
}


The problem: my input file is processed silently but the output shows two primers insted of one and the sequence is said to be NULL.

sequence: (null)
sequence: (null)


I'm blocked here :-)


Pierre

26 April 2007

New Journal: Human Frontier Science Program Journal


The HFSP Journal aims to publish high quality, innovative interdisciplinary basic research at the frontier of biology over a wide range of organizational levels (from the molecular level to population biology) using principles strategies or technologies from the more quantitative disciplines (e.g. physics, chemistry, mathematics, engineering, or informatics).

http://hfspj.aip.org/

Pubmed2connotea updated for Pubmed Beta.


I've updated the greasemonkey script 'pubmed2connotea'. The script alters the content of NCBI pubmed by inserting somes hyperlinks to connotea and it now works for the new pubmed beta.
I also added a hyperlink to http://del.icio.us.

see:


Updated 2010-08-12 source code

// pubmed2connotea
// version 0.4 BETA!
// 2007-04-26
// Copyright (c) 2006, 2007, Pierre Lindenbaum PhD
// Released under the GPL license
// http://www.gnu.org/copyleft/gpl.html
// http://www.integragen.com
// --------------------------------------------------------------------
//
// This is a Greasemonkey user script. To install it, you need
// Greasemonkey 0.6.4 or later: http://greasemonkey.mozdev.org/
// and Firefox 1.5 : http://www.mozilla.com/
// Then restart Firefox and revisit this script.
// Under Tools, there will be a new menu item to "Install User Script".
// Accept the default configuration and install.
//
// To uninstall, go to Tools/Manage User Scripts,
// select "pubmed2connotea", and click Uninstall.
//
// 2006-07: changed for abstract-plus
// 2007-04: pubmed beta
//
// --------------------------------------------------------------------

// ==UserScript==
// @name pubmed2connotea
// @namespace http://www.integragen.com
// @description insert a shortcut link used to add an entry in http://www.connotea.org or http://www.citeulike.org/ when browsing NCBI pubmed
// @include http://www.ncbi.nlm.nih.gov/entrez/*
// @include http://www.ncbi.nlm.nih.gov/sites/*
// @include http://www.ncbi.nlm.nih.gov/pubmed/*

// ==/UserScript==



function gm_xpath(expression,contextNode)
{
return document.evaluate(expression,contextNode,null,XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,null);
}

function getParameter(url,parameter)
{
if(url==null) return null;
parameter=parameter.toLowerCase();
var a= url.indexOf("?");
if(a==-1) return null;
if(url.toLowerCase().indexOf(parameter+"=")==-1) return null;
var params= url.substring(a+1).split("&");
var i=0;
for(i=0;i<params.length;i++)
{
b= params[i].indexOf("=");
if(b==-1) continue;
var key = params[i].substring(0,b).toLowerCase();
if(key!=parameter) continue;
return params[i].substring(b+1);
}
return null;
}

function hasParameter(url,key,value)
{
var s= getParameter(url,key);
return (s!=null && s.toLowerCase() == value.toLowerCase() );
}

function escapeURL(url)
{
var s="";
var i=0;

for(i=0;i< url.length;++i)
{
var c=url.charAt(i)
switch( c )
{
case ':': s+= '%3A'; break;
case '/': s+= '%2F'; break;
case '?': s+= '%3F'; break;
case '=': s+= '%3D'; break;
case '&': s+= '%26'; break;
default : s+= c; break;
}
}
return s;
}


function insertAnchors()
{

if(document.getElementsByTagName)
{
//hack found at http://erik.eae.net/archives/2005/06/10/22.21.42/#comment-5337
var inputElements = document.getElementsByTagName("input");
var i=0;
for (i=0; inputElements[i]!=null; i++)
{
inputElements[i].setAttribute("autocomplete","off");
}
}
}

var prefix="http://www.ncbi.nlm.nih.gov/pubmed/";
var allAnchors = gm_xpath("//a[@href]",document);

var i=0;
var prev=0;

for(i=0; i<allAnchors.snapshotLength; i++)
{
a = allAnchors.snapshotItem(i);
if(a.parentNode==null) continue;
var href=a.href;

var index=href.indexOf(prefix);


var list_uids="null";
if(index==-1){
var templocation=href.indexOf("IdsFromResult");
if(templocation!=-1){
list_uids=getParameter(href,"IdsFromResult");
index=0;
}
}

if(index==-1) continue;

if(href.indexOf("id=Limits")!=-1||
href.indexOf("id=Preview/Index")!=-1||
href.indexOf("id=History")!=-1||
href.indexOf("id=Clipboard")!=-1||
href.indexOf("id=Details")!=-1||
href.indexOf("filter=review&")!=-1
) continue;

if(list_uids=="null"){

qlocation=href.indexOf("?");
if(qlocation!=-1){
list_uids=href.substring(35,qlocation);//pmid starts at 35
}
}

if(list_uids!=prev){

href= "http://www.ncbi.nlm.nih.gov/entrez/query.fcgi?cmd=Retrieve&db=pubmed&dopt=Abstract&list_uids="+list_uids;
//href= "http://www.ncbi.nlm.nih.gov/entrez/query.fcgi?cmd=Retrieve&db=pubmed&list_uids="+list_uids;
prev=list_uids;

var newanchor = document.createElement("a");
newanchor.setAttribute("title","insert into www.connotea.org");
newanchor.setAttribute("target","connotea"+i+list_uids);
//addpopup?continue=confirm
//newanchor.setAttribute("href","http://www.connotea.org/addpopup?continue=confirm&uri="+escapeURL(href)+"&button=Look%20Up");
newanchor.setAttribute("href","http://www.connotea.org/addpopup?continue=confirm&uri="+escapeURL(href));

var img = document.createElement("img");
img.setAttribute("alt","insert into www.connotea.org");
img.setAttribute("src","http://www.connotea.org/connotea_icon.png");
img.setAttribute("border","0");

newanchor.appendChild(img);
//GM_log(a.href);
a.parentNode.insertBefore(newanchor,a);
a.parentNode.insertBefore(document.createTextNode(" "),a);

//now create link for citeulike

newanchor = document.createElement("a");
newanchor.setAttribute("title","insert into www.citeulike.org");
newanchor.setAttribute("target","citeulike"+i);
newanchor.setAttribute("href","http://www.citeulike.org/posturl?url="+escapeURL(href)+"&title=Entrez%20PubMed");

img = document.createElement("img");
img.setAttribute("alt","insert into www.citeulike.org");
img.setAttribute("src","http://static.citeulike.org/img/note.gif");
img.setAttribute("border","0");

newanchor.appendChild(img);
a.parentNode.insertBefore(newanchor,a);
a.parentNode.insertBefore(document.createTextNode(" "),a);


//now create link for del.icio.us

newanchor = document.createElement("a");
newanchor.setAttribute("title","insert into del.icio.us");
newanchor.setAttribute("target","delicious"+i);
newanchor.setAttribute("href","http://del.icio.us/post?url="+escapeURL(href));

img = document.createElement("img");
img.setAttribute("alt","insert into del.icio.us");
img.setAttribute("src","http://del.icio.us/favicon.ico");
img.setAttribute("border","0");

newanchor.appendChild(img);
a.parentNode.insertBefore(newanchor,a);
a.parentNode.insertBefore(document.createTextNode(" "),a);

}
}


window.addEventListener("load", insertAnchors, false);

22 April 2007

Freebase !

I finaly received my invitation to join freebase. Freebase ,which was previously introduced by Tim O'Reilly, is a structured semantic wiki. I tested it today: this is a great product. I consider the whole site as a RDF/RDFS editor where you can define classes , properties and create some instances. In consequence, Freebase is far more structured than wikipedia.

The site comes with a complete API (MQL Metaweb Query Language(looks like SPARQL)) which can be used to query freebase and to create your own application (e.g. see CineSpin).

Example: searching for physicists born between 1800 and 1900:


{
"query":[{
"/people/person/date_of_birth":null,
"/people/person/date_of_birth<":"1900",
"/people/person/date_of_birth>=":"1800",
"limit":35,
"name":null,
"type":"/science/physicist"
}]
}


Result:


{
"result":[{
"/people/person/date_of_birth":"1879-03-14",
"name":"Albert Einstein",
"type":"/science/physicist"
},{
"/people/person/date_of_birth":"1878",
"name":"Lise Meitner",
"type":"/science/physicist"
},{
"/people/person/date_of_birth":"1867",
"name":"Marie Curie",
"type":"/science/physicist"
},{
"/people/person/date_of_birth":"1844",
"name":"Ludwig Boltzmann",
"type":"/science/physicist"
}],
"status":"/mql/status/ok"
}


Considering bioinformatics many types could be created (I've no time to play with this at this time ! ): defining Molecular Interactions, Biologists, etc...

Pierre

12 April 2007

Web2.0 and Science: A Presentation using SLIDY

(via Sun)Slidy is a purely web based presentation tool that can be displayed in a modern browser. No need to mail slides around the world and clutter email boxes, no need for the recipient to download a huge binary: just send someone a URL to your slide..

I've tested Slidy tonight by writing a short presentation about my thoughts on the web2.0 and science. You can read this presentation at:



Pierre

11 April 2007

How blast works ?

A few years ago, I wondered how blast was implemented: was there a way to play the binary file where the sequences were indexed ? I had a glance at the NCBI C toolkit but I was a little bit lost with all that source code. I asked the question via usenet and I recieved a mail from M. Dumontier who suggested me to have a look at the SLRI toolkit:

The Samuel Lunenfeld Research Institute (SLRI) Toolkit is a cross-platform toolkit for manipulating biological information. The SLRI toolkit is based mainly in C and derives many functions from the NCBI toolkit. The SLRI toolkit was developed mainly for data pertaining to protein structure and function but can be used to manipulate other data such as gene sequences.

Last sunday, I added a new short entry into wikipedia about formatdb and I wondered again how the software was implemented: what is the format of those files ? how are packaged the protein , the degenerate nucleotides ? could I implement a reader/writer with another language (java ?) ? Just for my own curiosity I would be interested to have some more information about how blast was implemented. Feel free to add some more information about this subject in wikipedia.

Pierre


PS: The problem with wikipedia via http://xkcd.com/ :-)

21 March 2007

Geni, Graphiz, Dot & Family Tree.

Geni is a genealogy-related social networking website launched in beta mode in January 2007. Since yesterday, the family tree can now be exported as a gedcom-xml file (alpha version).

The following xslt stylesheet transforms the gedcom file into a Graphiz/DOT input which can be used to generate the family tree.

Family Tree



<?xml version='1.0' ?>
<xsl:stylesheet xmlns:xsl='http://www.w3.org/1999/XSL/Transform' version='1.0'>
<xsl:output method='text' omit-xml-declaration="yes" />

<xsl:template match="GEDCOM">
digraph &quot;G&quot; {
<xsl:apply-templates select="FamilyRec"/>
<xsl:apply-templates select="IndividualRec"/>
}
</xsl:template>

<xsl:template match="IndividualRec">
<xsl:value-of select="@Id"/>[ shape=box, label=&quot;<xsl:value-of select="IndivName/GivenName"/><xsl:text> </xsl:text><xsl:value-of select="IndivName/SurName"/> <xsl:if test="DeathStatus=&apos;dead;&apos;">(d)</xsl:if>&quot;

<xsl:choose>
<xsl:when test="Gender=&apos;M&apos;">
,color=blue
</xsl:when>
<xsl:when test="Gender=&apos;F&apos;">
,color=pink
</xsl:when>
<xsl:otherwise>
,color=black
</xsl:otherwise>
</xsl:choose>


];
</xsl:template>

<xsl:template match="FamilyRec">
<xsl:variable name="famId"><xsl:value-of select="@Id"/></xsl:variable>

<xsl:value-of select="$famId"/>[shape=point];

<xsl:if test="HusbFath">
<xsl:value-of select="HusbFath/Link/@Ref"/>-&gt;<xsl:value-of select="$famId"/>;
</xsl:if>

<xsl:if test="WifeMoth">
<xsl:value-of select="WifeMoth/Link/@Ref"/>-&gt;<xsl:value-of select="$famId"/>;
</xsl:if>

<xsl:for-each select="Child">
<xsl:value-of select="$famId"/>-&gt;<xsl:value-of select="Link/@Ref"/>;
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>



Pierre