Represents a nuclear family (father, mother, and at least one child).
| 51 | * Represents a nuclear family (father, mother, and at least one child). |
| 52 | */ |
| 53 | public class Family { |
| 54 | |
| 55 | /** Position of the first child in model array. */ |
| 56 | public static final int FIRST_CHILD_INDEX = 2; |
| 57 | /** Position of the mother in model array. */ |
| 58 | public static final int MOTHER_INDEX = 1; |
| 59 | /** Position of the father in model array. */ |
| 60 | public static final int FATHER_INDEX = 0; |
| 61 | |
| 62 | final String mFather; |
| 63 | final String mMother; |
| 64 | final Set<String> mChildren = new TreeSet<>(); |
| 65 | final GenomeRelationships mPedigree; |
| 66 | private final String[] mMembers; |
| 67 | private final boolean[] mIsDiseased; |
| 68 | private final int[] mSampleIds; |
| 69 | private int mFatherFamilyId; |
| 70 | private int mFatherDistinctMates = 1; |
| 71 | private int mMotherFamilyId; |
| 72 | private int mMotherDistinctMates = 1; |
| 73 | |
| 74 | |
| 75 | |
| 76 | /** |
| 77 | * Constructs a family from the provided pedigree. |
| 78 | * The file must contain only parent-child relationships |
| 79 | * Each child must share the same two parents. |
| 80 | * @param pedigree the GenomeRelationships which describes the family |
| 81 | * @return the identified family |
| 82 | * @throws PedigreeException if the genome file doesn't describe a simple family |
| 83 | */ |
| 84 | public static Family getFamily(GenomeRelationships pedigree) throws PedigreeException { |
| 85 | String firstParent = null; |
| 86 | String secondParent = null; |
| 87 | final String father; |
| 88 | final String mother; |
| 89 | final Set<String> children = new TreeSet<>(); |
| 90 | for (final String name : pedigree.genomes()) { |
| 91 | boolean found = false; |
| 92 | for (final Relationship r : pedigree.relationships(name, new RelationshipTypeFilter(RelationshipType.PARENT_CHILD))) { |
| 93 | if (r.first().equals(name)) { |
| 94 | if (!found) { |
| 95 | if (firstParent != null) { |
| 96 | throw new PedigreeException("There are more than two parents specified"); |
| 97 | } |
| 98 | firstParent = secondParent; |
| 99 | secondParent = name; |
| 100 | } |
| 101 | found = true; |
| 102 | } else { |
| 103 | children.add(name); |
| 104 | } |
| 105 | } |
| 106 | } |
| 107 | if (firstParent == null) { |
| 108 | throw new PedigreeException("There are fewer than two parents specified"); |
| 109 | } |
| 110 | if ((pedigree.getSex(firstParent) == Sex.FEMALE) || (pedigree.getSex(secondParent) == Sex.MALE)) { |
nothing calls this directly
no outgoing calls
no test coverage detected