Skip to content

Commit

Permalink
- NEW: Modified the loading code to take ABH data and split the H bac…
Browse files Browse the repository at this point in the history
…k into A/B. Refs #2.
  • Loading branch information
imilne committed Apr 8, 2021
1 parent bbf426f commit 32c76a3
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 2 deletions.
17 changes: 17 additions & 0 deletions src/jhi/flapjack/analysis/OptimizeStateTable.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,23 @@ public void collapseHomzEncodedAsHet()
optimize(true);
}

public void detectABH()
{
if (stateTable.containsABHData() == false)
return;

for (int i = 1; i < stateTable.size(); i++)
{
AlleleState s = stateTable.getAlleleState(i);

if (s.isHomozygous() && s.homzAllele().equals("H"))
{
s = new AlleleState("A/B", "/");
stateTable.getStates().set(i, s);
}
}
}

public void optimize(boolean compareHomzOnly)
{
// This lookup table will hold remapped references to the AlleleState
Expand Down
2 changes: 2 additions & 0 deletions src/jhi/flapjack/io/DataImporter.java
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ public void runJob(int jobIndex) throws Exception

// Collapse (eg) A/A into A
pio.collapseHomzEncodedAsHet();
// Change ABH data into A and B and A/B
pio.detectABH();
// Collapse heterozyous states
if (Prefs.ioHeteroCollapse)
pio.optimizeStateTable();
Expand Down
10 changes: 8 additions & 2 deletions src/jhi/flapjack/io/PostImportOperations.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ public void optimizeStateTable()
c.optimize(false);
}

public void detectABH()
{
OptimizeStateTable c = new OptimizeStateTable(dataSet);
c.detectABH();
}

public void setName(File importFile, BrapiClient client)
{
if (importFile != null)
Expand Down Expand Up @@ -91,8 +97,8 @@ else if (dataSet.getBinnedData().containsBins() || st.containsBins())
viewSet.setColorScheme(ColorScheme.BINNED_10);

// ABH
else if (dataSet.getStateTable().containsABHData())
viewSet.setColorScheme(ColorScheme.ABH_DATA);
// else if (dataSet.getStateTable().containsABHData())
// viewSet.setColorScheme(ColorScheme.ABH_DATA);
// Two colour
else if (hCount > 0 && hCount < 10)
viewSet.setColorScheme(ColorScheme.SIMPLE_TWO_COLOR);
Expand Down
1 change: 1 addition & 0 deletions src/jhi/flapjack/io/cmd/CreateProject.java
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ private void createProject()

PostImportOperations pio = new PostImportOperations(dataSet);
pio.collapseHomzEncodedAsHet();
pio.detectABH();
if (importSettings.isCollapseHeteozygotes())
pio.optimizeStateTable();
pio.createDefaultView(importSettings.isForceNucScheme());
Expand Down
1 change: 1 addition & 0 deletions src/jhi/flapjack/io/cmd/CreateProjectBatch.java
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ private void createProject(DataSet dataSet, File mapFile, File genoFile, String

PostImportOperations pio = new PostImportOperations(dataSet);
pio.collapseHomzEncodedAsHet();
pio.detectABH();
if (importSettings.isCollapseHeteozygotes())
pio.optimizeStateTable();
pio.createDefaultView(importSettings.isForceNucScheme());
Expand Down

0 comments on commit 32c76a3

Please sign in to comment.