Skip to content

Developer's Guide

gbeane edited this page Mar 10, 2011 · 6 revisions

The purpose of this documentation is to make it easier for developers to get started contributing to this project.

The Service Stack

The UI will be built with a mix of client site GWT and HTML/CSS. The server side with be a java web application which will contain GWT servlets and potentially other servlets for file upload etc.

Other potential APIs we may use:

  • JFreeChart for rendering graphs
  • Jersey for restful services
  • ...

Development Tools

Git

Revision control will be done using git and github. Any git client will do but if you're using Mac OS X gitx provides a nice GUI interface to the git commands. Here are some guidlines for how git should be used:

  • you should push/pull code changes to the canonical repository frequently. A day's worth of coding will usually include at least one commit. Keeping commits small and frequent helps to avoid the need for manual merges and also makes it easier for everyone to see how the code is evolving
  • always try to keep formatting/refactoring changes and algorithmic/feature changes in separate commits. Putting them in the same commit can make it difficult and error prone to make sense of the diffs and merge changes
  • when in doubt branch! Branches are perfect for any experimental or self-contained work that you are doing. Branches in git are easy to merge back into the master branch and pull requests are a great tool for doing code reviews before merging into the master branch.

Ant + Ivy

Ant and Ivy are used together as the build system for this project. Ivy is used to resolve dependencies (ie to fetch the jar files that our project file depends on) and ant is used to trigger ivy and build the java source code.

Eclipse

Any IDE or editor will do but your life may be a little bit easier if you use eclipse. To get started:

  • first do a clean build as described in the drake-genetics README.txt file
  • next start eclipse and import all projects that are under the root directory for drake-genetics: File -> Import ... -> Existing Projects into Workspace
  • You can always run ant from your terminal but if you want to run the ant build directly from eclipse you can go to Project -> Clean and select the option to clean all projects. After doing this you should see the output from an eclipse build in your IDE's "Console" window.

Note on Using Ivy With Eclipse

The projects that we have set up in eclipse depend on the jar files that ivy delivers to the lib directory. This means that if you ant clean your project and then refresh eclipse (you can use the F5 key to refresh) you will see project errors for the missing jar file. To correct this you just need to rebuild the project with ant which will recreate the lib directory. After that refresh your projects with F5 and the error messages should go away.

Debugging With Eclipse

In order to use the graphical debugger in eclipse you can do the following:

  • set any break points or conditions that you care about in eclipse
  • from the project's root directory run the command ant debug-devmode. This will trigger a clean build. After the build completes ant will wait for you to attach a debug session from eclipse
  • from eclipse you can now right click on the drake-genetics-server project and select Debug As -> Debug Configurations .... Now create a new Remote Java Application configuration. All of the default options should be correct.
  • Now the GWT DevMode shell should appear and you can click the Launch Default Browser button to start debugging.

Implementation Notes

Adding New Starting Drakes

Currently this requires adding Java code, recompiling, and redeploying since this is all hard coded. Eventually we would like this to be more configurable.

Adding new drakes on the front end

Adding new drakes on the back end

The GenotypeService on the back end will need to know how to genotype your Drakes (and their progeny). The GenotypingService contains a Map that maps haplotype IDs (Strings) to a Map of gene symbols (Strings) to alleles (Strings). Here is the declaration:

private Map<String, Map<String, String>> haplotypeToAlleles;

There is a private method in GenotypeService called init(), which is called from the constructor and initializes this map. Our starting drakes have been defined with a paternal haplotype ID and a maternal haplotype ID. These need to be added to our haplotypeToAlleles Map so that drakes with these haplotypes can be genotyped. Here is an example of a paternal and maternal haplotype that has been added to the map:

        //P1_M
        genotypeMap = new HashMap<String, String>();
        genotypeMap.put("Otc", "B");
        genotypeMap.put("Tyrp1", "Bog");
        genotypeMap.put("Myo5a", "D");
        genotypeMap.put("Ar", "Tr");
        genotypeMap.put("Dll3", "T");
        genotypeMap.put("M", "M");
        genotypeMap.put("Xdh","F");
        genotypeMap.put("Tyr", "C");
        genotypeMap.put("Pax6", "N");
        genotypeMap.put("Eda", "A1");
        genotypeMap.put("Dia", "Db");
        haplotypeToAlleles.put("P1_M", genotypeMap);

        //P1_P
        genotypeMap = new HashMap<String, String>();
        genotypeMap.put("Otc", "b");
        genotypeMap.put("Tyrp1", "bog");
        genotypeMap.put("Myo5a", "d");
        genotypeMap.put("Ar", "Tr");
        genotypeMap.put("Dll3", "t");
        genotypeMap.put("M", "m");
        genotypeMap.put("Xdh","f");
        genotypeMap.put("Tyr", "C");
        genotypeMap.put("Pax6", "n");
        genotypeMap.put("Eda", "A2");
        genotypeMap.put("Dia", "Db");
        haplotypeToAlleles.put("P1_P", genotypeMap);

This is a female drake, since the paternal haplotype includes alleles for X-linked genes. Now if any drake has the haplotype P1_P at any location on a chromosome we can look up the alleles for genes in that location.