use of javafx.scene.control.TableView in project jvarkit by lindenb.
the class BamStage method createMetaDataTable.
private TableView<SAMTagAndValue> createMetaDataTable() {
final TableView<SAMTagAndValue> table = new TableView<>();
table.getColumns().add(makeColumn("Key", O -> O.tag));
table.getColumns().add(makeColumn("Value", O -> O.value));
table.setPlaceholder(new Label("No Meta-data."));
return table;
}
use of javafx.scene.control.TableView in project jvarkit by lindenb.
the class BamStage method createPileupTable.
private TableView<Pileup> createPileupTable() {
final TableView<Pileup> table = new TableView<>();
table.getColumns().add(makeColumn("REF", O -> O.contig));
table.getColumns().add(formatIntegerColumn(makeColumn("POS", O -> O.position)));
table.getColumns().add(makeColumn("Depth", O -> O.depth()));
table.getColumns().add(makeColumn("A", O -> O.count[0]));
table.getColumns().add(makeColumn("T", O -> O.count[1]));
table.getColumns().add(makeColumn("G", O -> O.count[2]));
table.getColumns().add(makeColumn("C", O -> O.count[3]));
table.getColumns().add(makeColumn("N", O -> O.count[4]));
table.getColumns().add(makeColumn("Bases", O -> O.seq.toString()));
table.getColumns().add(makeColumn("Qual", O -> O.qual.toString()));
table.getColumns().add(makeColumn("Operators", O -> O.operators.toString()));
table.setPlaceholder(new Label("No Pileup data."));
return table;
}
use of javafx.scene.control.TableView in project jvarkit by lindenb.
the class BamStage method makeRecordTable.
private TableView<SAMRecord> makeRecordTable() {
final Font font1 = new Font("Courier", 9);
/* get max SEQ length displayed */
int prefnum = 0;
try {
prefnum = Integer.parseInt(this.owner.preferences.get(this.owner.pref_bam_max_seq_length_displayed.key, "500"));
} catch (final NumberFormatException err) {
prefnum = 500;
}
final int max_seq_length = prefnum;
/* get MAX number of items in cigar */
try {
prefnum = Integer.parseInt(this.owner.preferences.get(this.owner.pref_bam_max_cigar_items_displayed.key, "50"));
} catch (final NumberFormatException err) {
prefnum = 50;
}
final int max_items_in_cigar = prefnum;
/* utility function to make column specific of paired data */
final Function<TableColumn<SAMRecord, ?>, TableColumn<SAMRecord, ?>> insertPairdColumn = TC -> {
this.pairedEndColumns.add(TC);
return TC;
};
final TableView<SAMRecord> table = new TableView<SAMRecord>();
table.getColumns().add(makeColumn("Read-Name", REC -> REC.getReadName()));
table.getColumns().add(makeColumn("Flag", REC -> REC.getFlags()));
table.getColumns().add(makeColumn("Ref", REC -> REC.getReferenceName()));
table.getColumns().add(formatIntegerColumn(makeColumn("UStart", REC -> {
if (REC.getReadUnmappedFlag() || REC.getCigar() == null)
return null;
final int upos = REC.getUnclippedStart();
if (upos == REC.getAlignmentStart())
return null;
return upos;
})));
table.getColumns().add(formatIntegerColumn(makeColumn("Start", REC -> {
final int pos = REC.getAlignmentStart();
if (pos == SAMRecord.NO_ALIGNMENT_START)
return null;
return pos;
})));
table.getColumns().add(formatIntegerColumn(makeColumn("End", REC -> {
final int pos = REC.getAlignmentEnd();
if (pos == SAMRecord.NO_ALIGNMENT_START)
return null;
return pos;
})));
table.getColumns().add(formatIntegerColumn(makeColumn("UEnd", REC -> {
if (REC.getReadUnmappedFlag() || REC.getCigar() == null)
return null;
final int upos = REC.getUnclippedEnd();
if (upos == REC.getAlignmentEnd())
return null;
return upos;
})));
table.getColumns().add(makeColumn("MAPQ", REC -> REC.getMappingQuality()));
TableColumn<SAMRecord, Cigar> tc0 = makeColumn("CIGAR", REC -> REC.getCigar());
tc0.setCellFactory(tv -> new TableCell<SAMRecord, Cigar>() {
final TextFlow textFlow = new TextFlow();
@Override
protected void updateItem(final Cigar cigar, boolean empty) {
super.updateItem(cigar, empty);
setText(null);
setTextOverrun(OverrunStyle.CLIP);
if (cigar == null || cigar.isEmpty()) {
// setText(null);
setGraphic(null);
return;
}
if (cigar.numCigarElements() >= max_items_in_cigar) {
setGraphic(null);
setText(" num(items) > " + max_items_in_cigar);
return;
}
final List<Text> L = new ArrayList<>(cigar.numCigarElements());
for (final CigarElement ce : cigar.getCigarElements()) {
final Text txt = new Text(String.valueOf(ce.getLength()) + (char) CigarOperator.enumToCharacter(ce.getOperator()));
txt.setFont(font1);
switch(ce.getOperator()) {
case H:
case S:
txt.setStroke(Color.ORANGE);
break;
case X:
case N:
case D:
case I:
txt.setStroke(Color.RED);
break;
case M:
txt.setStroke(Color.BLUE);
break;
case EQ:
txt.setStroke(Color.GREEN);
break;
case P:
txt.setStroke(Color.GRAY);
break;
default:
txt.setStroke(Color.BLACK);
break;
}
L.add(txt);
}
this.textFlow.setLineSpacing(0.1);
this.textFlow.setMaxHeight(10);
this.textFlow.setPrefHeight(10);
this.textFlow.getChildren().setAll(L);
this.setGraphic(textFlow);
}
});
table.getColumns().add(tc0);
table.getColumns().add(insertPairdColumn.apply(formatIntegerColumn(makeColumn("LEN", REC -> !REC.getReadPairedFlag() || REC.getMateUnmappedFlag() ? null : REC.getInferredInsertSize()))));
table.getColumns().add(insertPairdColumn.apply(makeColumn("Mate-Ref", REC -> !REC.getReadPairedFlag() || REC.getMateUnmappedFlag() ? null : REC.getMateReferenceName())));
table.getColumns().add(insertPairdColumn.apply(formatIntegerColumn(makeColumn("Mate-Pos", REC -> !REC.getReadPairedFlag() || REC.getMateUnmappedFlag() ? null : REC.getMateAlignmentStart()))));
TableColumn<SAMRecord, String> tc = makeColumn("SEQ", REC -> REC.getReadString());
// http://stackoverflow.com/questions/42187987/
tc.setCellFactory(tv -> new TableCell<SAMRecord, String>() {
final TextFlow textFlow = new TextFlow();
@Override
protected void updateItem(final String item, boolean empty) {
super.updateItem(item, empty);
setText(null);
setTextOverrun(OverrunStyle.CLIP);
if (item == null) {
// setText(null);
setGraphic(null);
return;
}
if (item.length() >= max_seq_length) {
setGraphic(null);
setText("len > " + max_seq_length);
return;
}
final List<Text> L = new ArrayList<>(item.length());
for (int i = 0; i < item.length(); ++i) {
final Text txt = new Text(String.valueOf(item.charAt(i)));
txt.setFont(font1);
txt.setStroke(JfxNgs.BASE2COLOR.apply(item.charAt(i)));
L.add(txt);
}
this.textFlow.setLineSpacing(0.1);
this.textFlow.setMaxHeight(10);
this.textFlow.setPrefHeight(10);
this.textFlow.getChildren().setAll(L);
this.setGraphic(textFlow);
}
});
table.getColumns().add(tc);
tc = makeColumn("QUAL", REC -> REC.getBaseQualityString());
tc.setCellFactory(tv -> new TableCell<SAMRecord, String>() {
final TextFlow textFlow = new TextFlow();
@Override
protected void updateItem(final String item, boolean empty) {
super.updateItem(item, empty);
setTextOverrun(OverrunStyle.CLIP);
setText(null);
if (item == null) {
// setText(null);
setGraphic(null);
return;
}
if (item.length() >= max_seq_length) {
setGraphic(null);
setText("len > " + max_seq_length);
return;
}
final List<Text> L = new ArrayList<>(item.length());
for (int i = 0; i < item.length(); ++i) {
char c = item.charAt(i);
int ch = (int) c;
double qual = 93.0;
if (!(ch < 33 || ch > 126)) {
qual = SAMUtils.fastqToPhred(c);
}
final Text txt = new Text(String.valueOf(c));
txt.setFont(font1);
txt.setStroke(Color.gray(qual / 93.0));
L.add(txt);
}
this.textFlow.setLineSpacing(0.1);
this.textFlow.setMaxHeight(10);
this.textFlow.setPrefHeight(10);
this.textFlow.getChildren().setAll(L);
this.setGraphic(textFlow);
}
});
table.getColumns().add(tc);
final short SA = SAMTagUtil.getSingleton().makeBinaryTag("SA");
table.getColumns().add(makeColumn("SA", REC -> REC.getAttribute(SA) == null ? null : "*"));
table.getColumns().add(makeColumn("NM", REC -> REC.getIntegerAttribute("NM")));
table.setPlaceholder(new Label("No Read."));
final ContextMenu ctxMenu = new ContextMenu();
ctxMenu.getItems().addAll(super.buildItemsForContextMenu());
table.setContextMenu(ctxMenu);
return table;
}
use of javafx.scene.control.TableView in project jvarkit by lindenb.
the class BamStage method createCigarTable.
/**
* create the Table showing the bases in a CIGAR string
*/
private TableView<CigarAndBase> createCigarTable() {
final TableView<CigarAndBase> table = new TableView<>();
table.getColumns().add(makeColumn("REF", O -> O.ref));
table.getColumns().add(formatIntegerColumn(makeColumn("Read-Pos", O -> O.posInRead)));
table.getColumns().add(formatIntegerColumn(makeColumn("Ref-Pos", O -> O.posInRef)));
table.getColumns().add(makeColumn("OP", new Function<CigarAndBase, String>() {
@Override
public String apply(final CigarAndBase param) {
return param.op == null ? null : param.op.name();
}
}));
table.getColumns().add(formatIntegerColumn(makeColumn("Len", O -> O.count)));
table.getColumns().add(makeColumn("Read-Bases", new Function<CigarAndBase, String>() {
@Override
public String apply(final CigarAndBase param) {
return param.base == null ? null : String.valueOf((char) param.base.intValue());
}
}));
table.setPlaceholder(new Label("No Cigar Data."));
return table;
}
use of javafx.scene.control.TableView in project jvarkit by lindenb.
the class BamStage method createProgramRecordPane.
private Tab createProgramRecordPane(final SAMFileHeader header) {
final TableView<SAMProgramRecord> table = new TableView<>(header == null ? FXCollections.observableArrayList() : FXCollections.observableArrayList(header.getProgramRecords()));
table.getColumns().add(makeColumn("ID", G -> G.getId()));
table.getColumns().add(makeColumn("PG-ID", G -> G.getProgramGroupId()));
table.getColumns().add(makeColumn("Prev-PG-ID", G -> G.getPreviousProgramGroupId()));
table.getColumns().add(makeColumn("Version", G -> G.getProgramVersion()));
table.getColumns().add(makeColumn("Command", G -> G.getCommandLine()));
final Tab tab = new Tab("PG", table);
tab.setClosable(false);
table.setPlaceholder(new Label("No Program-Group."));
return tab;
}
Aggregations