Skip to content
Snippets Groups Projects
Commit 36cbfe1c authored by tcarver's avatar tcarver
Browse files

fixes for writing out variant sites

parent a4a90080
Branches
Tags
No related merge requests found
......@@ -179,7 +179,7 @@ class IOUtils
protected static void exportVariantFasta(final VCFview vcfView)
{
final EntryGroup entryGroup = vcfView.getEntryGroup();
final int length = entryGroup.getSequenceLength();
int length = entryGroup.getSequenceLength();
final Bases bases = entryGroup.getBases();
final FeatureVector features = entryGroup.getAllFeatures();
......@@ -223,6 +223,7 @@ class IOUtils
int baseCount = 0;
// write variant sites to tmp files
//length = 2172095;
for(int i=0; i<length; i+=MAX_BASE_CHUNK)
{
int start = i+1;
......@@ -352,7 +353,6 @@ class IOUtils
final char basesC[] = bases.getSubSequenceC(new Range(start, end), Bases.FORWARD);
for (int i = start; i < end; i++)
{
int basePosition = i;
int thisSample = 0;
final String[] thisBase = new String[ntotalSamples+1];
......@@ -368,13 +368,14 @@ class IOUtils
if(record == null)
continue;
boolean vcf_v4 = reader.isVcf_v4();
int nsamples = reader.getNumberOfSamples();
// loop over each sample
for(int k=0; k<nsamples; k++)
{
// look at each type of variant
if(vcfView.showVariant(record, features, basePosition, reader, k, j) )
if(vcfView.showVariant(record, features, i, reader, k, j) )
{
if(record.getAlt().isDeletion(vcf_v4))
{
......@@ -401,9 +402,17 @@ class IOUtils
else if(record.getAlt().isNonVariant())
thisBase[thisSample] = ".";
else
{
if(record.getAlt().toString().length() > 1 &&
record.getAlt().toString().length() == record.getRef().length() )
{
thisBase[thisSample] = record.getAlt().toString();
seenSNP = true;
if(thisBase[ntotalSamples] == null ||
thisBase[ntotalSamples].length() < record.getRef().length())
thisBase[ntotalSamples] = record.getRef();
}
}
}
else
......@@ -416,6 +425,7 @@ class IOUtils
if(seenSNP)
{
// look-up reference base
if(thisBase[ntotalSamples] == null)
thisBase[ntotalSamples] = String.valueOf( basesC[i-start] );
int remainder = 0;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment