A method of testing for a genetic alteration at one or more loci in a sample comprising a mixture of maternal and fetal DNA polynucleotides, comprising the steps of: a. obtaining maternal and fetal polynucleotides in a test sample; b. hybridizing a plurality of molecular inversion probes (MIPs), each MIP comprising a first hybridization sequence, a second hybridization sequence, two or more universal priming sites, and an identifier, wherein the plurality of MIPs comprises a plurality of MIPs directed to at least one locus of interest and a plurality of MIPs directed to at least one reference locus outside the locus of interest in the sample comprising maternal and fetal polynucleotides; c. optionally extending hybridization sequences using polymerase; d. ligating MIPs to produce circular ligation products, wherein each of the circular ligation products is produced from one MIP; e. isolating bound circular ligation products from unbound, linear MIPs; f. amplifying a region from a ligation product using the two or more universal priming sites, wherein the region comprises the identifier; g. enumerating the identifiers within the ligation products; and h. determining the presence or absence of a genetic alteration at one or more loci, optionally comprising determining the sex of a fetus; wherein the identifier is a molecular barcode; wherein a first unique identifier is assigned to the MIPs targeting the at least one locus of interest and a second unique identifier is assigned to the MIPs targeting the at least one reference locus; and wherein the first and second hybridization sequence of a MIP directed to at least one locus of interest bind sites on an identical strand of a polynucleotide sequence in the locus of interest. a. obtaining maternal and fetal polynucleotides in a test sample; b. hybridizing a plurality of molecular inversion probes (MIPs), each MIP comprising a first hybridization sequence, a second hybridization sequence, two or more universal priming sites, and an identifier, wherein the plurality of MIPs comprises a plurality of MIPs directed to at least one locus of interest and a plurality of MIPs directed to at least one reference locus outside the locus of interest in the sample comprising maternal and fetal polynucleotides; c. optionally extending hybridization sequences using polymerase; d. ligating MIPs to produce circular ligation products, wherein each of the circular ligation products is produced from one MIP; e. isolating bound circular ligation products from unbound, linear MIPs; f. amplifying a region from a ligation product using the two or more universal priming sites, wherein the region comprises the identifier; g. enumerating the identifiers within the ligation products; and h. determining the presence or absence of a genetic alteration at one or more loci, optionally comprising determining the sex of a fetus; wherein the identifier is a molecular barcode; wherein a first unique identifier is assigned to the MIPs targeting the at least one locus of interest and a second unique identifier is assigned to the MIPs targeting the at least one reference locus; and wherein the first and second hybridization sequence of a MIP directed to at least one locus of interest bind sites on an identical strand of a polynucleotide sequence in the locus of interest. wherein the identifier is a molecular barcode; wherein a first unique identifier is assigned to the MIPs targeting the at least one locus of interest and a second unique identifier is assigned to the MIPs targeting the at least one reference locus; and wherein the first and second hybridization sequence of a MIP directed to at least one locus of interest bind sites on an identical strand of a polynucleotide sequence in the locus of interest. <EOS>