Skip to content

Commit

Permalink
New GeometricSeqPhenotype class (#22)
Browse files Browse the repository at this point in the history
* Created a GeometricSeqPhenotype class that implements Phenotype and uses composition

* Maintain translation from nucleotides to amino acids

* Precompute vectors from gamma distribution

* Made sure nucleotide is being mutated to a different letter.

* Test matrix of vectors drawn from the gamma distribution

* Remove gamma distribution csv output from repo

* Keep mutating until it's not a stop codon

* if mutation creates a stop codon, switch index to mutate

* represent sequence using a char[]

* use inheritance instead of composition

* Clean up code, add documentation

* finish unit tests for geometricseq

* clean up repo

* each sentence gets own line.

* Address Hugh and Zorian's comments. First round.

* Remove SequencePhenotype.java

* Fix issue #23

* Remove DMS file requirement

* Clean up code and refactor sanity check

* Created a GeometricSeqPhenotype class that implements Phenotype and uses composition

* Maintain translation from nucleotides to amino acids

* Precompute vectors from gamma distribution

* Made sure nucleotide is being mutated to a different letter.

* Test matrix of vectors drawn from the gamma distribution

* Remove gamma distribution csv output from repo

* Keep mutating until it's not a stop codon

* if mutation creates a stop codon, switch index to mutate

* represent sequence using a char[]

* use inheritance instead of composition

* Clean up code, add documentation

* finish unit tests for geometricseq

* clean up repo

* Address Hugh and Zorian's comments. First round.

* Fix issue #23

* Remove DMS file requirement

* Clean up code and refactor sanity check

* format updates.

* remove illegal characters from filename

* update readme

* Nonfunctional changes to code from Erick's review of PR #22

* Test CodonMap values are correct

* Update out.tips for GeometricSeq fields

* change names from traitA/B to ag1/2 to consistency

* Clean up commented and unused code

* print fasta for branches

* Add startingSequence and epitopeSites files and output fasta file

* Initial commit for testing geometric seq phenotype without predefined dictionary of vectors

* Clean up and refactor things

* Fix bug with reset and organize/optimize a little more in GeometricSeqPhenotype.java

* Make sure that the nucleotide sequence is updated even for synonymous mutations

* fasta file rename for pipeline

* Update README.md

* updates to params for customization of output path

* remove .out from outputs

* Add headers to fasta file sequences

* Update to deme name instead of ID

* allow last codon to be a stop

* log file creation

* file formatting

---------

Co-authored-by: Zorian Thornton <[email protected]>
  • Loading branch information
thienktran and zorian15 authored Jun 20, 2023
1 parent 0cc19ec commit 25ad694
Show file tree
Hide file tree
Showing 19 changed files with 1,951 additions and 988 deletions.
4 changes: 3 additions & 1 deletion Antigen.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
/* Implements an individual-based model in which the infection's genealogical history is tracked through time */

import java.io.FileNotFoundException;

class Antigen {
public static void main(String[] args) {
public static void main(String[] args) throws FileNotFoundException {

// initialize random number generator
cern.jet.random.AbstractDistribution.makeDefaultGenerator();
Expand Down
428 changes: 428 additions & 0 deletions Biology.java

Large diffs are not rendered by default.

376 changes: 376 additions & 0 deletions GeometricSeqPhenotype.java

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion HostPopulation.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class HostPopulation {
private double tmrca;
private double netau;
private double serialInterval;
private double antigenicDiversity;
private double antigenicDiversity;

private int newContacts;
private int newRecoveries;
Expand Down
290 changes: 184 additions & 106 deletions Parameters.java

Large diffs are not rendered by default.

13 changes: 10 additions & 3 deletions PhenotypeFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ public class PhenotypeFactory {
public static String GEOMETRIC3D = "geometric3d";
public static String GEOMETRIC10D = "geometric10d";
public static String SEQUENCE = "sequence";
public static String GEOMETRIC_SEQ = "geometricSeq";

// returns newly instantiated Phenotype objects of type according to Parameters.phenotypeSpace
public static Phenotype makeVirusPhenotype() {
Expand All @@ -15,7 +16,7 @@ public static Phenotype makeVirusPhenotype() {
if (GEOMETRIC.equals(Parameters.phenotypeSpace)) { p = new GeometricPhenotype(); }
if (GEOMETRIC3D.equals(Parameters.phenotypeSpace)) { p = new GeometricPhenotype3D(); }
if (GEOMETRIC10D.equals(Parameters.phenotypeSpace)) { p = new GeometricPhenotype10D(); }
if (SEQUENCE.equals(Parameters.phenotypeSpace)) { p = new SequencePhenotype(); }
if (GEOMETRIC_SEQ.equals(Parameters.phenotypeSpace)) { p = new GeometricSeqPhenotype(); }
return p;

}
Expand All @@ -34,8 +35,13 @@ public static Phenotype makeHostPhenotype() {
double[] traits = {Parameters.initialTraitA, 0, 0, 0, 0, 0, 0, 0, 0, 0};
p = new GeometricPhenotype10D(traits);
}
if (SEQUENCE.equals(Parameters.phenotypeSpace)) {
p = new SequencePhenotype(Parameters.startingSequence);
if (GEOMETRIC_SEQ.equals(Parameters.phenotypeSpace)) {
String startingSequence = Parameters.startingSequence;
if (startingSequence == null) {
p = new GeometricSeqPhenotype(Parameters.initialTraitA, 0);
} else {
p = new GeometricSeqPhenotype(Parameters.initialTraitA, 0, Parameters.startingSequence.toCharArray());
}
}
return p;

Expand All @@ -46,6 +52,7 @@ public static Phenotype makeArbitaryPhenotype(double x, double y) {

Phenotype p = null;
if (GEOMETRIC.equals(Parameters.phenotypeSpace)) { p = new GeometricPhenotype(x, y); }
if (GEOMETRIC_SEQ.equals(Parameters.phenotypeSpace)) { p = new GeometricSeqPhenotype(x, y); }
return p;

}
Expand Down
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,25 @@ rate of within deme contact.

## Running

### Setting up Java on Fred Hutch cluster


To load Java 11, run these commands:

source /app/lmod/lmod/init/profile
ml Java/11;



The program can be compiled with:

javac *.java


I (@zorian15) have found that I sometimes need to specify all of the `.jar` files in the compilation command to get things to compile completely, this can be done with::

javac -classpath ".:lib/classmexer.jar:lib/colt-1.2.0.jar:lib/hamcrest-core-1.3.jar:lib/junit-4.13.1.jar:" *.java

Then to run:

java -XX:+UseSerialGC -Xmx1G Antigen
Expand Down
41 changes: 20 additions & 21 deletions Random.java
Original file line number Diff line number Diff line change
@@ -1,54 +1,53 @@
/* Holds random number genator necessities */
/* Trying to encapsulate this, so the RNG particulars can be changed if necessary */
/* Trying to encapsulate this, so the RNG particulars can be changed if necessary */
/* Completely static class, allows no instances to be instantiated */

//import cern.jet.random.*;
import cern.jet.random.*;

public class Random {

// methods

public static int nextInt(int from, int to) {
return cern.jet.random.Uniform.staticNextIntFromTo(from, to);
}
}

public static double nextDouble() {
return cern.jet.random.Uniform.staticNextDouble();
return cern.jet.random.Uniform.staticNextDouble();
}

public static double nextDouble(double from, double to) {
return cern.jet.random.Uniform.staticNextDoubleFromTo(from, to);
}
return cern.jet.random.Uniform.staticNextDoubleFromTo(from, to);
}

public static double nextNormal() {
return cern.jet.random.Normal.staticNextDouble(0.0,1.0);
return cern.jet.random.Normal.staticNextDouble(0.0, 1.0);
}

public static double nextNormal(double mean, double sd) {
return cern.jet.random.Normal.staticNextDouble(mean,sd);
}
return cern.jet.random.Normal.staticNextDouble(mean, sd);
}

// tuned with mean
public static double nextExponential(double lambda) {
return cern.jet.random.Exponential.staticNextDouble(1.0/lambda);
return cern.jet.random.Exponential.staticNextDouble(1.0 / lambda);
}

// tuned with alpha and beta, matching Mathematica's notation
public static double nextGamma(double alpha, double beta) {
return cern.jet.random.Gamma.staticNextDouble(alpha, 1/beta);
}
return cern.jet.random.Gamma.staticNextDouble(alpha, 1 / beta);
}

public static int nextPoisson(double lambda) {
return cern.jet.random.Poisson.staticNextInt(lambda);
}

public static boolean nextBoolean(double p) {
boolean x = false;
if (nextDouble() < p) {
x = true;
}
return x;
}

}

}
225 changes: 0 additions & 225 deletions SequencePhenotype.java

This file was deleted.

Loading

0 comments on commit 25ad694

Please sign in to comment.