Newer
Older
/* VCFview
*
* created: July 2010
*
* This file is part of Artemis
*
* Copyright(C) 2010 Genome Research Limited
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*/
package uk.ac.sanger.artemis.components.variant;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Insets;
import java.awt.Point;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.AdjustmentEvent;
import java.awt.event.AdjustmentListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseMotionListener;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.swing.JCheckBoxMenuItem;
import javax.swing.JFrame;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JPanel;
import javax.swing.JPopupMenu;
import javax.swing.JScrollBar;
import javax.swing.JScrollPane;
import javax.swing.border.Border;
import javax.swing.border.EmptyBorder;
import net.sf.samtools.util.BlockCompressedInputStream;
import org.apache.log4j.Level;
import uk.ac.sanger.artemis.Entry;
import uk.ac.sanger.artemis.EntryGroup;
import uk.ac.sanger.artemis.Feature;
import uk.ac.sanger.artemis.FeatureKeyPredicate;
import uk.ac.sanger.artemis.FeatureVector;
import uk.ac.sanger.artemis.SelectionChangeEvent;
import uk.ac.sanger.artemis.SelectionChangeListener;
import uk.ac.sanger.artemis.components.DisplayAdjustmentEvent;
import uk.ac.sanger.artemis.components.DisplayAdjustmentListener;
import uk.ac.sanger.artemis.components.FeatureDisplay;
import uk.ac.sanger.artemis.components.FileViewer;
import uk.ac.sanger.artemis.components.MessageDialog;
import uk.ac.sanger.artemis.components.alignment.FileSelectionDialog;
import uk.ac.sanger.artemis.editor.MultiLineToolTipUI;
import uk.ac.sanger.artemis.io.EmblStreamFeature;
import uk.ac.sanger.artemis.io.EntryInformation;
import uk.ac.sanger.artemis.io.InvalidRelationException;
import uk.ac.sanger.artemis.io.Key;
import uk.ac.sanger.artemis.io.Location;
import uk.ac.sanger.artemis.io.Qualifier;
import uk.ac.sanger.artemis.io.QualifierVector;
import uk.ac.sanger.artemis.io.RangeVector;
import uk.ac.sanger.artemis.sequence.AminoAcidSequence;
import uk.ac.sanger.artemis.sequence.MarkerRange;
import uk.ac.sanger.artemis.sequence.NoSequenceException;
import uk.ac.sanger.artemis.util.Document;
import uk.ac.sanger.artemis.util.DocumentFactory;
import uk.ac.sanger.artemis.util.OutOfRangeException;
public class VCFview extends JPanel
implements DisplayAdjustmentListener, SelectionChangeListener
{
private static final long serialVersionUID = 1L;
private JScrollBar scrollBar;
private FeatureDisplay feature_display;
private EntryGroup entryGroup;
private String chr;
private String mouseOverVCFline;
private int mouseOverIndex = -1;
//record of where a mouse drag starts
private int dragStart = -1;
private boolean showSynonymous = true;
private boolean showNonSynonymous = true;
private boolean showDeletions = true;
private boolean showInsertions = true;
private boolean showMultiAlleles = true;
new JCheckBoxMenuItem("Mark new stops within CDS features", true);
// show variants that do not overlap CDS
private boolean showNonOverlappings = true;
Hashtable<String, Integer> offsetLengths = null;
private boolean concatSequences = false;
private Pattern multiAllelePattern = Pattern.compile("^[AGCT]+,[AGCT,]+$");
protected static Pattern tabPattern = Pattern.compile("\t");
public VCFview(final JFrame frame,
final JPanel vcfPanel,
final List<String> vcfFiles,
final int nbasesInView,
final int seqLength,
final String chr,
final String reference,
final FeatureDisplay feature_display)
{
super();
this.nbasesInView = nbasesInView;
this.seqLength = seqLength;
this.chr = chr;
this.feature_display = feature_display;
this.vcfPanel = vcfPanel;
setBackground(Color.white);
MultiLineToolTipUI.initialize();
setToolTipText("");
vcfPanel.setPreferredSize(new Dimension(900,
(vcfFiles.size()+1)*(LINE_HEIGHT+5)));
this.entryGroup = feature_display.getEntryGroup();
this.entryGroup = getReference(reference);
if(entryGroup != null)
this.seqLength = entryGroup.getSequenceEntry().getBases().getLength();
try
{
tr = new TabixReader[vcfFiles.size()];
header = new String[vcfFiles.size()];
for(int i=0; i<vcfFiles.size(); i++)
{
header[i] = readHeader(vcfFiles.get(i));
tr[i] = new TabixReader(vcfFiles.get(i));
}
}
catch(java.lang.UnsupportedClassVersionError err)
{
JOptionPane.showMessageDialog(null,
"This requires Java 1.6 or higher.",
"Check Java Version", JOptionPane.WARNING_MESSAGE);
}
catch (IOException e)
{
e.printStackTrace();
}
final JScrollPane jspView = new JScrollPane(this,
JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
vcfPanel.setLayout(new BorderLayout());
vcfPanel.add(jspView, BorderLayout.CENTER);
if(this.nbasesInView > this.seqLength)
this.nbasesInView = this.seqLength/2;
scrollBar = new JScrollBar(JScrollBar.HORIZONTAL, 1, this.nbasesInView, 1, this.seqLength);
scrollBar.setUnitIncrement(nbasesInView/20);
scrollBar.addAdjustmentListener(new AdjustmentListener()
{
public void adjustmentValueChanged(AdjustmentEvent e)
{
repaint();
}
});
//
//
addMouseListener(new PopupListener());
//
setDisplay();
if(feature_display == null)
{
vcfPanel.add(scrollBar, BorderLayout.SOUTH);
frame.pack();
frame.setVisible(true);
}
else
{
Border empty = new EmptyBorder(0,0,0,0);
jspView.setBorder(empty);
private void createMenus(JFrame frame, final JScrollPane jspView)
if(feature_display != null)
topPanel = new JPanel(new FlowLayout(FlowLayout.LEADING, 0, 0));
else
{
markNewStops.setSelected(false);
markNewStops.setEnabled(false);
topPanel = new JMenuBar();
frame.setJMenuBar((JMenuBar)topPanel);
JMenu fileMenu = new JMenu("File");
topPanel.add(fileMenu);
JMenuItem printImage = new JMenuItem("Save As Image Files (png/jpeg)...");
printImage.addActionListener(new ActionListener()
public void actionPerformed(ActionEvent e)
{
PrintVCFview part = new PrintVCFview(VCFview.this);
part.print();
}
});
fileMenu.add(printImage);
JMenuItem printPS = new JMenuItem("Print...");
printPS.addActionListener(new ActionListener()
public void actionPerformed(ActionEvent e)
{
PrintVCFview part = new PrintVCFview(VCFview.this);
part.validate();
part.doPrintActions();
}
});
fileMenu.add(printPS);
JMenuItem close = new JMenuItem("Close");
fileMenu.add(close);
close.addActionListener(new ActionListener()
public void actionPerformed(ActionEvent e)
{
VCFview.this.setVisible(false);
Component comp = VCFview.this;
while( !(comp instanceof JFrame) )
comp = comp.getParent();
((JFrame)comp).dispose();
}
});
JButton zoomIn = new JButton("-");
Insets ins = new Insets(1,1,1,1);
zoomIn.setMargin(ins);
zoomIn.addActionListener(new ActionListener()
public void actionPerformed(ActionEvent e)
{
setZoomLevel((int) (VCFview.this.nbasesInView * 1.1));
}
});
topPanel.add(zoomIn);
JButton zoomOut = new JButton("+");
zoomOut.setMargin(ins);
zoomOut.addActionListener(new ActionListener()
public void actionPerformed(ActionEvent e)
{
setZoomLevel((int) (VCFview.this.nbasesInView * .9));
}
});
topPanel.add(zoomOut);
}
if(tr[0].getmSeq().length > 1)
combo.setSelectedItem(this.chr);
combo.setEditable(false);
combo.setMaximumRowCount(20);
combo.addItemListener(new ItemListener()
{
public void itemStateChanged(ItemEvent e)
{
if(combo.getSelectedItem().equals("Combine References"))
concatSequences = true;
else
{
VCFview.this.chr = (String) combo.getSelectedItem();
concatSequences = false;
}
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
if(topPanel instanceof JPanel)
vcfPanel.add(topPanel, BorderLayout.NORTH);
// auto hide top panel
final JCheckBox buttonAutoHide = new JCheckBox("Hide", true);
buttonAutoHide.setToolTipText("Auto-Hide");
topPanel.add(buttonAutoHide);
final MouseMotionListener mouseMotionListener = new MouseMotionListener()
{
public void mouseDragged(MouseEvent event)
{
handleCanvasMouseDrag(event);
}
public void mouseMoved(MouseEvent e)
{
findVariantAtPoint(e.getPoint());
int thisHgt = HEIGHT;
if (thisHgt < 5)
thisHgt = 15;
int y = (int) (e.getY() - jspView.getViewport().getViewRect().getY());
if (y < thisHgt)
topPanel.setVisible(true);
else
{
if (buttonAutoHide.isSelected())
topPanel.setVisible(false);
}
}
};
addMouseMotionListener(mouseMotionListener);
// popup menu
popup = new JPopupMenu();
JMenuItem addVCFMenu = new JMenuItem("Add VCF ...");
addVCFMenu.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
FileSelectionDialog fileSelection = new FileSelectionDialog(
null, true, "VCFview", "VCF");
List<String> vcfFileList = fileSelection.getFiles(".*\\.vcf(\\.gz)*$");
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
int count = vcfFileList.size();
int oldSize = tr.length;
TabixReader[] trTmp = new TabixReader[count + tr.length];
System.arraycopy(tr, 0, trTmp, 0, tr.length);
tr = trTmp;
String[] hdTmp = new String[count + tr.length];
System.arraycopy(header, 0, hdTmp, 0, header.length);
header = hdTmp;
try
{
for (int i = 0; i < vcfFileList.size(); i++)
{
header[i+oldSize] = readHeader(vcfFileList.get(i));
tr[i+oldSize] = new TabixReader(vcfFileList.get(i));
}
}
catch (IOException ioe)
{
ioe.printStackTrace();
}
setDisplay();
repaint();
jspView.revalidate();
}
});
popup.add(addVCFMenu);
popup.addSeparator();
JMenu showMenu = new JMenu("Show");
popup.add(showMenu);
final JCheckBoxMenuItem showSyn = new JCheckBoxMenuItem(
"Synonymous", showSynonymous);
showSyn.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e)
{
showSynonymous = showSyn.isSelected();
repaint();
}
});
final JCheckBoxMenuItem showNonSyn = new JCheckBoxMenuItem(
"Non-synonymous", showNonSynonymous);
showNonSyn.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e)
{
showNonSynonymous = showNonSyn.isSelected();
repaint();
}
});
showMenu.add(showNonSyn);
final JCheckBoxMenuItem showDeletionsMenu = new JCheckBoxMenuItem(
"Deletions", showDeletions);
showDeletionsMenu.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e)
{
showDeletions = showDeletionsMenu.isSelected();
repaint();
}
});
showMenu.add(showDeletionsMenu);
final JCheckBoxMenuItem showInsertionsMenu = new JCheckBoxMenuItem(
"Insertions", showInsertions);
showInsertionsMenu.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e)
{
showInsertions = showInsertionsMenu.isSelected();
repaint();
}
});
showMenu.add(showInsertionsMenu);
final JCheckBoxMenuItem showMultiAllelesMenu = new JCheckBoxMenuItem(
"Multiple alleles", showMultiAlleles);
showMultiAllelesMenu.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e)
{
showMultiAlleles = showMultiAllelesMenu.isSelected();
repaint();
}
});
showMenu.add(showMultiAllelesMenu);
final JCheckBoxMenuItem showNonOverlappingsMenu = new JCheckBoxMenuItem(
"Varaints not overlapping CDS", showNonOverlappings);
showNonOverlappingsMenu.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e)
{
showNonOverlappings = showNonOverlappingsMenu.isSelected();
repaint();
}
});
showMenu.add(showNonOverlappingsMenu);
markNewStops.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e)
{
if(!markNewStops.isSelected())
markAsNewStop = false;
repaint();
}
});
popup.add(markNewStops);
final JMenuItem filterByQuality = new JMenuItem("Filter by quality");
filterByQuality.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e)
{
//
String inputValue = JOptionPane.showInputDialog(null,
"Enter a minimum quality score:", MIN_QUALITY);
if(inputValue == null)
return;
try
{
MIN_QUALITY = Float.parseFloat(inputValue);
repaint();
}
catch(NumberFormatException ex)
{
JOptionPane.showMessageDialog(null,
"Number "+inputValue+" not recognised.",
"Format Error", JOptionPane.ERROR_MESSAGE);
}
}
});
popup.add(filterByQuality);
final JMenuItem exportVCF = new JMenuItem("Export filtered VCF");
exportVCF.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e)
{
IOUtils.export(entryGroup, vcfFiles, VCFview.this);
}
});
popup.add(exportVCF);
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
private static EntryGroup getReference(String reference)
{
EntryGroup entryGroup = new SimpleEntryGroup();
final Document entry_document = DocumentFactory.makeDocument(reference);
final EntryInformation artemis_entry_information =
Options.getArtemisEntryInformation();
final uk.ac.sanger.artemis.io.Entry new_embl_entry =
EntryFileDialog.getEntryFromFile(null, entry_document,
artemis_entry_information,
false);
if(new_embl_entry != null) // the read failed
{
Entry entry = null;
Bases bases = null;
try
{
if (entryGroup.getSequenceEntry() != null)
bases = entryGroup.getSequenceEntry().getBases();
if (bases == null)
{
entry = new Entry(new_embl_entry);
bases = entry.getBases();
}
else
entry = new Entry(bases, new_embl_entry);
entryGroup.add(entry);
}
catch (OutOfRangeException e)
{
new MessageDialog(null, "read failed: one of the features in "
+ reference + " has an out of range " + "location: "
+ e.getMessage());
}
catch (NoSequenceException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
}
return entryGroup;
}
/**
* Read the vcf header
* @param fileName
* @return
*/
private String readHeader(final String fileName)
{
StringBuffer buff = new StringBuffer();
buff.append(fileName+"\n");
try
{
if(IOUtils.isBCF(fileName))
{
JOptionPane.showMessageDialog(null,
"Looks like a BCF formated file.\n"+
"Convert to VCF and use bgzip and tabix\n"+
"to compress and index respectively.",
"Unsupported Format",
JOptionPane.WARNING_MESSAGE);
}
BlockCompressedInputStream is =
new BlockCompressedInputStream(new FileInputStream(fileName));
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
buff.append(line+"\n");
}
}
catch (IOException e)
{
e.printStackTrace();
}
return buff.toString();
}
/**
* Set the number of bases being displayed
* @param nbasesInView
*/
private void setZoomLevel(final int nbasesInView)
{
int startValue = scrollBar.getValue();
this.nbasesInView = nbasesInView;
float pixPerBase = getPixPerBaseByWidth();
this.nbasesInView = (int)(getWidth()/pixPerBase);
if(scrollBar != null)
{
scrollBar.setValues(startValue, nbasesInView, 1, seqLength);
scrollBar.setUnitIncrement(nbasesInView/20);
scrollBar.setBlockIncrement(nbasesInView);
}
}
public String getToolTipText()
{
if(mouseOverVCFline == null)
return null;
String msg =
"Seq: "+parts[0]+"\n";
msg += "Pos: "+parts[1]+"\n";
msg += "ID: "+parts[2]+"\n";
msg += "Variant: "+parts[3]+" -> "+parts[4]+"\n";
msg += "Qual: "+parts[5]+"\n";
return msg;
}
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
/**
* For VCF files with multiple references sequences, calculate
* the offset from the start of the concatenated sequence for
* a given reference.
* @param refName
* @return
*/
protected int getSequenceOffset(String refName)
{
if(!concatSequences)
return 0;
if(offsetLengths == null)
{
String[] contigs = tr[0].getmSeq();
FeatureVector features = entryGroup.getAllFeatures();
offsetLengths = new Hashtable<String, Integer>(contigs.length);
for(int i=0; i<contigs.length; i++)
{
FeatureContigPredicate predicate = new FeatureContigPredicate(contigs[i]);
for(int j=0; j<features.size(); j++)
{
if(predicate.testPredicate(features.elementAt(j)))
{
offsetLengths.put(contigs[i], features.elementAt(j).getFirstBase()-1);
break;
}
}
}
tjc
committed
if(offsetLengths.size() != contigs.length)
JOptionPane.showMessageDialog(this,
"There is a problem matching the reference sequences\n"+
"to the names in the VCF file. This may mean the labels\n"+
"on the reference features do not match those in the in\n"+
"the VCF file.",
"Problem Found", JOptionPane.WARNING_MESSAGE);
}
return offsetLengths.get(refName);
}
protected void paintComponent(Graphics g)
{
super.paintComponent(g);
mouseOverVCFline = null;
float pixPerBase = getPixPerBaseByWidth();
drawSelectionRange((Graphics2D)g, pixPerBase, start, end);
FeatureVector features = getCDSFeaturesInRange(start, end);
String[] contigs = tr[0].getmSeq();
for(int j=0; j<contigs.length; j++)
{
int offset = getSequenceOffset(contigs[j]);
int nextOffset;
if(j<contigs.length-1)
nextOffset = getSequenceOffset(contigs[j+1]);
else
nextOffset = seqLength;
if( (offset >= start && offset < end) ||
(offset < start && start < nextOffset) )
{
int thisStart = start - offset;
if(thisStart < 1)
thisStart = 1;
int thisEnd = end - offset;
drawRegion(g, contigs[j]+":"+thisStart+"-"+thisEnd, i, start, pixPerBase, features);
}
}
}
else
{
int thisStart = start;
if(thisStart < 1)
thisStart = 1;
drawRegion(g, chr+":"+thisStart+"-"+end, i, start, pixPerBase, features);
}
if(feature_display == null)
drawScale((Graphics2D)g, start, end, pixPerBase, getHeight());
}
private void drawRegion(Graphics g,
String region,
int i,
int start,
float pixPerBase,
FeatureVector features)
{
String s;
TabixReader.Iterator iter = tr[i].query(region); // get the iterator
if (iter == null)
return;
try
{
while ((s = iter.next()) != null)
drawVariantCall(g, s, start, i, pixPerBase, features);
}
catch (IOException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
}
private FeatureVector getCDSFeaturesInRange(int start, int end)
{
try
{
Range range = new Range(start, end);
FeatureVector features = entryGroup.getFeaturesInRange(range);
FeatureKeyPredicate predicate = new FeatureKeyPredicate(Key.CDS);
final FeatureVector cdsFeatures = new FeatureVector();
for(int i=0; i<features.size(); i++)
{
final Feature this_feature = features.elementAt(i);
if(predicate.testPredicate(this_feature))
cdsFeatures.add(this_feature);
}
return cdsFeatures;
}
catch (OutOfRangeException e1)
{
e1.printStackTrace();
}
return null;
}
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
/**
* Highlight a selected range
* @param g2
* @param pixPerBase
* @param start
* @param end
*/
private void drawSelectionRange(Graphics2D g2, float pixPerBase, int start, int end)
{
if(getSelection() != null)
{
Range selectedRange = getSelection().getSelectionRange();
if(selectedRange != null)
{
int rangeStart = selectedRange.getStart();
int rangeEnd = selectedRange.getEnd();
if(end < rangeStart || start > rangeEnd)
return;
int x = (int) (pixPerBase*(rangeStart-getBaseAtStartOfView()));
int width = (int) (pixPerBase*(rangeEnd-rangeStart+1));
g2.setColor(Color.pink);
g2.fillRect(x, 0, width, getHeight());
}
}
}
private Selection getSelection()
{
return selection;
protected int getBaseAtStartOfView()
{
if(feature_display != null)
return feature_display.getForwardBaseAtLeftEdge();
else
return scrollBar.getValue();
}
/**
* Is this a deletion type.
* @param variant
* @return
*/
if(vcf_v4)
{
if( variant.length() < ref.length() && !(variant.indexOf(",") > -1) )
return true;
}
else if(variant.indexOf("D")>-1)
return true;
return false;
}
/**
* Is this an insertion type.
* @param variant
* @return
*/
if(vcf_v4)
{
if( variant.length() > ref.length() && !(variant.indexOf(",") > -1) )
return true;
}
else if(variant.indexOf("I")>-1)
return true;
return false;
}
protected boolean showVariant(String ref, String variant, FeatureVector features, int basePosition, String quality)
return false;
return false;
try
{
if(Float.parseFloat(quality) < MIN_QUALITY)
return false;
}
catch(NumberFormatException e)
{
System.err.println(e.getMessage());
}
if(!showNonOverlappings && !isOverlappingFeature(features, basePosition))
return false;
int isSyn = -1;
if(markNewStops.isSelected() &&
!isDeletion(ref, variant) &&
!isInsertion(ref, variant) &&
variant.length() == 1 &&
ref.length() == 1)
{
isSyn = isSynonymous(features, basePosition, variant.toLowerCase().charAt(0));
if(isSyn == 2)
markAsNewStop = true;
else
markAsNewStop = false;
}
if( (!showSynonymous || !showNonSynonymous) &&
!isDeletion(ref, variant) &&
!isInsertion(ref, variant) &&
variant.length() == 1 &&
ref.length() == 1)
if(isSyn == -1)
isSyn = isSynonymous(features, basePosition, variant.toLowerCase().charAt(0));
if( (!showSynonymous && isSyn == 1) ||
(!showNonSynonymous && isSyn != 1 ) )
return false;
if(!showMultiAlleles && multiAllelePattern.matcher(variant).matches())
return false;
return true;
}
private boolean isOverlappingFeature(FeatureVector features, int basePosition)
{
for(int i = 0; i<features.size(); i++)
{
Feature feature = features.elementAt(i);
if(feature.getRawFirstBase() < basePosition && feature.getRawLastBase() > basePosition)
{
RangeVector ranges = feature.getLocation().getRanges();
for(int j=0; j< ranges.size(); j++)
{
Range range = (Range) ranges.get(j);
if(range.getStart() < basePosition && range.getEnd() > basePosition)
return true;
}
}
}
return false;
}
private void drawVariantCall(Graphics g, String line, int start, int index, float pixPerBase, FeatureVector features)
{
//String parts[] = line.split("\\t");
String parts[] = tabPattern.split(line, 0);
int basePosition = Integer.parseInt(parts[1]) + getSequenceOffset(parts[0]);
if( !showVariant(parts[3], parts[4], features, basePosition, parts[5]) )
return;
int pos[] = getScreenPosition(basePosition, pixPerBase, start, index);
if(isDeletion(parts[3], parts[4]))
g.setColor(Color.gray);
else if(isInsertion(parts[3], parts[4]))
g.setColor(Color.yellow);
else if(parts[4].equals("C") && parts[3].length() == 1)