use of com.github.lindenb.jvarkit.pedigree.Status in project jvarkit by lindenb.
the class SwingVCFGenotypesTableModel method setRows.
@Override
public synchronized void setRows(final List<Genotype> genotypes) {
if (genotypes == null) {
setRows(Collections.emptyList());
}
this.columns.clear();
final Vector<ColumnInfo> columns = new Vector<>();
ColumnInfo ci = new ColumnInfo();
ci.clazz = String.class;
ci.name = "Sample";
ci.extractor = GT -> GT.getSampleName();
columns.add(ci);
if (this.pedigree != null) {
ci = new ColumnInfo();
ci.clazz = String.class;
ci.name = "Status";
ci.extractor = GT -> {
final Sample sn = this.pedigree.getSampleById(GT.getSampleName());
if (sn == null || !sn.isStatusSet())
return null;
if (sn.getStatus().equals(Status.affected))
return "[*]";
if (sn.getStatus().equals(Status.unaffected))
return "[ ]";
return null;
};
columns.add(ci);
}
if (genotypes.stream().anyMatch(G -> G.isAvailable())) {
ci = new ColumnInfo();
ci.clazz = String.class;
ci.name = VCFConstants.GENOTYPE_KEY;
ci.extractor = GT -> GT.getAlleles().stream().map(A -> A.getDisplayString()).collect(Collectors.joining(GT.isPhased() ? Genotype.PHASED_ALLELE_SEPARATOR : Genotype.UNPHASED_ALLELE_SEPARATOR));
columns.add(ci);
}
ci = new ColumnInfo();
ci.clazz = String.class;
ci.name = "Type";
ci.extractor = GT -> GT.getType().name();
columns.add(ci);
if (genotypes.stream().anyMatch(G -> G.hasDP())) {
ci = new ColumnInfo();
ci.clazz = String.class;
ci.name = VCFConstants.DEPTH_KEY;
ci.extractor = GT -> GT.hasDP() ? GT.getDP() : null;
columns.add(ci);
}
if (genotypes.stream().anyMatch(G -> G.hasGQ())) {
ci = new ColumnInfo();
ci.clazz = String.class;
ci.name = VCFConstants.GENOTYPE_QUALITY_KEY;
ci.extractor = GT -> GT.hasGQ() ? GT.getGQ() : null;
columns.add(ci);
}
if (genotypes.stream().anyMatch(G -> G.hasAD())) {
ci = new ColumnInfo();
ci.clazz = String.class;
ci.name = VCFConstants.GENOTYPE_ALLELE_DEPTHS;
ci.extractor = GT -> GT.hasAD() ? Arrays.stream(GT.getAD()).mapToObj(P -> String.valueOf(P)).collect(Collectors.joining(",")) : null;
columns.add(ci);
}
if (genotypes.stream().anyMatch(G -> G.hasPL())) {
ci = new ColumnInfo();
ci.clazz = String.class;
ci.name = VCFConstants.GENOTYPE_PL_KEY;
ci.extractor = GT -> GT.hasPL() ? Arrays.stream(GT.getPL()).mapToObj(P -> String.valueOf(P)).collect(Collectors.joining(",")) : null;
columns.add(ci);
}
for (final String att : genotypes.stream().flatMap(G -> G.getExtendedAttributes().keySet().stream()).collect(Collectors.toSet())) {
ci = new ColumnInfo();
ci.clazz = Object.class;
ci.name = att;
ci.extractor = GT -> GT.hasExtendedAttribute(att) ? GT.getExtendedAttribute(att) : null;
columns.add(ci);
}
this.columns.addAll(columns);
super.rows.clear();
super.rows.addAll(genotypes);
fireTableStructureChanged();
}
Aggregations