| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
package dr.evolution; |
| 27 |
|
| 28 |
import java.util.ArrayList; |
| 29 |
import java.util.Iterator; |
| 30 |
import java.util.List; |
| 31 |
|
| 32 |
import dr.evolution.alignment.Alignment; |
| 33 |
import dr.evolution.tree.Tree; |
| 34 |
import dr.evolution.util.Taxa; |
| 35 |
import dr.evolution.util.Taxon; |
| 36 |
import dr.evolution.util.TaxonList; |
| 37 |
import dr.util.Attributable; |
| 38 |
import dr.util.Identifiable; |
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
public class MetagenomeData implements Attributable, Identifiable { |
| 44 |
|
| 45 |
protected String id = null; |
| 46 |
protected Alignment alignment; |
| 47 |
protected Taxa referenceTaxa; |
| 48 |
protected Taxa reads; |
| 49 |
protected LinkageConstraints constraints; |
| 50 |
protected boolean fixedReferenceTree; |
| 51 |
|
| 52 |
public MetagenomeData(TaxonList taxa, Alignment alignment) |
| 53 |
{ |
| 54 |
this(taxa, alignment, null, false); |
| 55 |
} |
| 56 |
public MetagenomeData(TaxonList taxa, Alignment alignment, LinkageConstraints constraints, boolean fixedReferenceTree) |
| 57 |
{ |
| 58 |
this.alignment = alignment; |
| 59 |
this.constraints = constraints; |
| 60 |
this.fixedReferenceTree = fixedReferenceTree; |
| 61 |
referenceTaxa = new Taxa(taxa.asList()); |
| 62 |
if(fixedReferenceTree == true && !(taxa instanceof Tree)){ |
| 63 |
throw new RuntimeException("Error, a tree must be provided in order to fix the topology of reference taxa"); |
| 64 |
} |
| 65 |
reads = new Taxa(); |
| 66 |
List<Taxon> alltaxa = alignment.asList(); |
| 67 |
for(int i=0; i<alltaxa.size(); i++) |
| 68 |
{ |
| 69 |
if(!referenceTaxa.contains(alltaxa.get(i))) |
| 70 |
reads.addTaxon(alltaxa.get(i)); |
| 71 |
} |
| 72 |
if(constraints==null){ |
| 73 |
this.constraints = new LinkageConstraints(new ArrayList<LinkedGroup>()); |
| 74 |
} |
| 75 |
} |
| 76 |
|
| 77 |
public TaxonList getReferenceTaxa(){ |
| 78 |
return referenceTaxa; |
| 79 |
} |
| 80 |
public TaxonList getReadsTaxa(){ |
| 81 |
return reads; |
| 82 |
} |
| 83 |
|
| 84 |
public Alignment getAlignment() { |
| 85 |
return alignment; |
| 86 |
} |
| 87 |
|
| 88 |
public void setAlignment(Alignment alignment) { |
| 89 |
this.alignment = alignment; |
| 90 |
} |
| 91 |
|
| 92 |
public ArrayList<LinkedGroup> getConstraints(){ |
| 93 |
return constraints.getLinkedGroups(); |
| 94 |
} |
| 95 |
|
| 96 |
public boolean getFixedReferenceTree(){ |
| 97 |
return fixedReferenceTree; |
| 98 |
} |
| 99 |
public void setFixedReferenceTree(boolean fixedReferenceTree){ |
| 100 |
this.fixedReferenceTree = fixedReferenceTree; |
| 101 |
} |
| 102 |
|
| 103 |
public String getId() { |
| 104 |
return id; |
| 105 |
} |
| 106 |
|
| 107 |
public void setId(String id) { |
| 108 |
this.id = id; |
| 109 |
} |
| 110 |
|
| 111 |
|
| 112 |
|
| 113 |
|
| 114 |
private Attributable.AttributeHelper attributes = null; |
| 115 |
|
| 116 |
|
| 117 |
|
| 118 |
|
| 119 |
|
| 120 |
|
| 121 |
|
| 122 |
public void setAttribute(String name, Object value) { |
| 123 |
if (attributes == null) |
| 124 |
attributes = new Attributable.AttributeHelper(); |
| 125 |
attributes.setAttribute(name, value); |
| 126 |
} |
| 127 |
|
| 128 |
|
| 129 |
|
| 130 |
|
| 131 |
|
| 132 |
public Object getAttribute(String name) { |
| 133 |
if (attributes == null) |
| 134 |
return null; |
| 135 |
else |
| 136 |
return attributes.getAttribute(name); |
| 137 |
} |
| 138 |
|
| 139 |
|
| 140 |
|
| 141 |
|
| 142 |
public Iterator<String> getAttributeNames() { |
| 143 |
if (attributes == null) |
| 144 |
return null; |
| 145 |
else |
| 146 |
return attributes.getAttributeNames(); |
| 147 |
} |
| 148 |
|
| 149 |
} |