[Swift-user] BioInformatics app question

Ben Clifford benc at hawaga.org.uk
Tue Jul 15 05:30:41 CDT 2008


this is not particularly elegant, but it will mostly do what i think you 
want:

make two custom mappers as shell scripts:

$ cat inmapper 
#!/bin/bash

i=0

ls data/* | while read n; do

echo [$i] $n
i=$(( $i + 1 ))

done



and medmapper contains:

$ cat medmapper 
#!/bin/bash

i=0

ls data/* | while read n; do

echo [$i].left ${n}.left
echo [$i].right ${n}.right
i=$(( $i + 1 ))

done


This pair relies on the fact that mapping will happen at the start and 
that ls will return files in the same order in both of them.

Then you can use them like this:

type file;

type medfiles {
  file left;
  file right;
}

(medfiles o) preprocess(file i) {
  o.left = touch();
  o.right = touch();
}

compare(file l, file r, medfiles lm, medfiles rm) {
  trace("comparing ", at l," and ", at r);
  process(lm.left);
  process(rm.left);
}

(file f) touch() {
  app {
    echo "hi" stdout=@f;
  }

process(file f) {
  app {
   cat "/dev/null" ;
  }
}

file inputs[] <ext;exec="./inmapper">;

medfiles intermediates[] <ext;exec="./medmapper">;

foreach input,i in inputs {

 intermediates[i] = preprocess(input);

}

foreach left, il in inputs {
  foreach right, ir in inputs {
    compare(left, right, intermediates[il], intermediates[ir]);
  }
}


Also, because the intermediate files are stored in the same directory as 
the source data, and there is nothing in the mappers to detect if a file 
is an input or intermediate file, then if you run the same workflow twice 
you will find the previous generations .left and .right files being picked 
up as inputs. You will need to rm -v data/*.left data/*.right between 
runs. This could be fixed in the mappers in a couple of ways, left as an 
exercise to the reader.

A more elegant solution might involve the mapper for intermediates[] doing 
a transform on the way that inputs[] is mapped, but there is no mapper to 
do that at the moment in a way that is useful here. (I have some thoughts 
about what it would look like but they are not developed enough for 
implementation).

-- 





More information about the Swift-user mailing list