Skip to content

Commit

Permalink
Added License
Browse files Browse the repository at this point in the history
  • Loading branch information
michael committed Nov 9, 2015
1 parent ce78491 commit 1b41ec3
Show file tree
Hide file tree
Showing 7 changed files with 2,232 additions and 1 deletion.
2 changes: 1 addition & 1 deletion JacusaHelper/DESCRIPTION
Expand Up @@ -6,4 +6,4 @@ Date: 2015-10-23
Author: Michael Piechotta
Maintainer: <michael.piechotta@age.mpg.de>
Description: This package enables to process JACUSA output: read, filter, process, plot, write
License: None
License: GNU Affero General Public License, Version 3.0
674 changes: 674 additions & 0 deletions JacusaHelper/R/LICENSE

Large diffs are not rendered by default.

674 changes: 674 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

21 changes: 21 additions & 0 deletions src/jacusa/JACUSA.java
@@ -1,5 +1,26 @@
/*
JAVA framework for accurate SNV assessment (JACUSA) is a one-stop solution to detect single
nucleotide variants (SNVs) from comparing matched sequencing samples.
Copyright (C) 2015 Michael Piechotta
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

package jacusa;



import jacusa.cli.parameters.AbstractParameters;
import jacusa.cli.parameters.CLI;
import jacusa.cli.parameters.hasSample2;
Expand Down
170 changes: 170 additions & 0 deletions src/jacusa/io/format/ConsensusOutputFormat.java
@@ -0,0 +1,170 @@
package jacusa.io.format;

import jacusa.filter.FilterConfig;
import jacusa.phred2prob.Phred2Prob;
import jacusa.pileup.BaseConfig;
import jacusa.pileup.ParallelPileup;
import jacusa.pileup.Pileup;
import jacusa.pileup.Result;

public class ConsensusOutputFormat extends AbstractOutputFormat {

public static final char CHAR = 'C';

public static final char COMMENT= '#';
public static final char EMPTY = '*';
public static final char SEP = '\t';
public static final char SEP2 = ',';

protected FilterConfig filterConfig;
protected BaseConfig baseConfig;
public Phred2Prob phred2Prob;

public ConsensusOutputFormat(
final char c,
final String desc,
final BaseConfig baseConfig,
final FilterConfig filterConfig) {
super(c, desc);

this.baseConfig = baseConfig;
this.filterConfig = filterConfig;

phred2Prob = Phred2Prob.getInstance(baseConfig.getBaseLength());
}

public ConsensusOutputFormat(
final BaseConfig baseConfig,
final FilterConfig filterConfig) {
this(CHAR, "Consensus", baseConfig, filterConfig);
}

@Override
public String getHeader(String[] pathnames1, String[] pathnames2) {
final StringBuilder sb = new StringBuilder();

sb.append(COMMENT);

// position (0-based)
sb.append("contig");
sb.append(getSEP());
sb.append("start");
sb.append(getSEP());
sb.append("end");
sb.append(getSEP());

sb.append("name");
sb.append(getSEP());

// stat
sb.append("stat");
sb.append(getSEP());

sb.append("strand");
sb.append(getSEP());

sb.append("consensus");

sb.append(getSEP());
sb.append("info");

// add filtering info
if (filterConfig.hasFiters()) {
sb.append(getSEP());
sb.append("filter_info");
}

return sb.toString();
}

protected void addSampleHeader(StringBuilder sb, char sample, int replicates) {
sb.append("bases");
sb.append(sample);
sb.append(1);
if (replicates == 1) {
return;
}

for (int i = 2; i <= replicates; ++i) {
sb.append(SEP);
sb.append("bases");
sb.append(sample);
sb.append(i);
}
}

@Override
public String convert2String(Result result) {
final ParallelPileup parallelPileup = result.getParellelPileup();
final double statistic = result.getStatistic();
final StringBuilder sb = new StringBuilder();

// coordinates
sb.append(parallelPileup.getContig());
sb.append(SEP);
sb.append(parallelPileup.getStart() - 1);
sb.append(SEP);
sb.append(parallelPileup.getEnd());

sb.append(SEP);
sb.append("variant");

sb.append(SEP);
if (Double.isNaN(statistic)) {
sb.append("NA");
} else {
sb.append(statistic);
}

sb.append(SEP);
sb.append(parallelPileup.getStrand().character());

addPileups(sb, parallelPileup.getPooledPileup());

sb.append(getSEP());
sb.append(result.getResultInfo().combine());

// add filtering info
if (filterConfig.hasFiters()) {
sb.append(getSEP());
sb.append(result.getFilterInfo().combine());
}

return sb.toString();
}

/*
* Helper function
*/
protected void addPileups(StringBuilder sb, Pileup pileup) {
// output sample: Ax,Cx,Gx,Tx

int maxBaseI = -1;
int count = Integer.MIN_VALUE;
for (int baseI : pileup.getAlleles()) {
if (pileup.getCounts().getBaseCount(baseI) > count) {
maxBaseI = baseI;
count = pileup.getCounts().getBaseCount(baseI);
}
}
sb.append(SEP);
sb.append(baseConfig.getBases()[maxBaseI]);
}

public char getCOMMENT() {
return COMMENT;
}

public char getEMPTY() {
return EMPTY;
}

public char getSEP() {
return SEP;
}

public char getSEP2() {
return SEP2;
}

}

0 comments on commit 1b41ec3

Please sign in to comment.