def setUp(self): self.common_data = create_common_entities() self.project = self.common_data['project'] self.pos_elem_tups = [ (968327, 'IS150'), (1305482, 'IS150'), (4517605, 'IS186')] graph_test_dir = os.path.join(GF_TEST_DIR, 'graph_tests') contig_alignment_bam = os.path.join( graph_test_dir, 'contig_alignment.bam') contig_alignment_to_me_bam = os.path.join( graph_test_dir, 'contig_alignment_to_me.bam') # Create graph G = nx.DiGraph() # Create sequence interval instances for reference and each contig ref_intervals = SequenceIntervals( 'ref', 4622887, tag='ref') G.ref_intervals = ref_intervals add_alignment_to_graph(G, contig_alignment_bam) add_me_alignment_to_graph(G, contig_alignment_to_me_bam) self.me_iv_pairs = me_translocation_walk(G)
def setUp(self): self.common_data = create_common_entities() self.project = self.common_data['project'] self.pos_elem_tups = [(968327, 'IS150'), (1305482, 'IS150'), (4517605, 'IS186')] graph_test_dir = os.path.join(GF_TEST_DIR, 'graph_tests') contig_alignment_bam = os.path.join(graph_test_dir, 'contig_alignment.bam') contig_alignment_to_me_bam = os.path.join( graph_test_dir, 'contig_alignment_to_me.bam') # Create graph G = nx.DiGraph() # Create sequence interval instances for reference and each contig ref_intervals = SequenceIntervals('ref', 4622887, tag='ref') G.ref_intervals = ref_intervals add_alignment_to_graph(G, contig_alignment_bam) add_me_alignment_to_graph(G, contig_alignment_to_me_bam) self.me_iv_pairs = me_translocation_walk(G)
def setUp(self): common_entities = create_common_entities() project = common_entities['project'] self.ref_genome_1 = common_entities['reference_genome'] self.chromosome = common_entities['chromosome'] self.sample_1 = ExperimentSample.objects.create( project=project, label=SAMPLE_1_LABEL) # Create 100 variants with alts, positions 1 to 100. # We add them to a fake VariantSet so that they show up in the # materialized variant view table. self.first_variant_position = 1 self.num_variants = 100 fake_variant_set = VariantSet.objects.create( reference_genome=self.ref_genome_1, label='fake') alignment_group = AlignmentGroup.objects.create( label='Alignment 1', reference_genome=self.ref_genome_1, aligner=AlignmentGroup.ALIGNER.BWA) for position in xrange(self.first_variant_position, self.first_variant_position + self.num_variants): variant = Variant.objects.create( type=Variant.TYPE.TRANSITION, reference_genome=self.ref_genome_1, chromosome=self.chromosome, position=position, ref_value='A') variant.variantalternate_set.add( VariantAlternate.objects.create( variant=variant, alt_value='G')) vccd = VariantCallerCommonData.objects.create( variant=variant, source_dataset_id=1, alignment_group=alignment_group, data={}) VariantEvidence.objects.create( experiment_sample=self.sample_1, variant_caller_common_data=vccd, data={}) VariantToVariantSet.objects.create( variant=variant, variant_set=fake_variant_set) self.var_set1 = VariantSet.objects.create( reference_genome=self.ref_genome_1, label=VARIANTSET_1_LABEL) self.var_set2 = VariantSet.objects.create( reference_genome=self.ref_genome_1, label=VARIANTSET_2_LABEL)
def setUp(self): self.common_entities = create_common_entities() self.ref_genome = import_reference_genome_from_local_file( self.common_entities['project'], 'ref_genome', TEST_FASTA, 'fasta') ref_genome_source = self.ref_genome.dataset_set.get( type=Dataset.TYPE.REFERENCE_GENOME_FASTA)\ .get_absolute_location() with open(ref_genome_source) as fh: self.ref_genome_seq_record = SeqIO.read(fh, 'fasta')
def setUp(self): common_entities = create_common_entities() project = common_entities['project'] self.ref_genome_1 = common_entities['reference_genome'] self.chromosome = common_entities['chromosome'] self.sample_1 = ExperimentSample.objects.create(project=project, label=SAMPLE_1_LABEL) # Create 100 variants with alts, positions 1 to 100. # We add them to a fake VariantSet so that they show up in the # materialized variant view table. self.first_variant_position = 1 self.num_variants = 100 fake_variant_set = VariantSet.objects.create( reference_genome=self.ref_genome_1, label='fake') alignment_group = AlignmentGroup.objects.create( label='Alignment 1', reference_genome=self.ref_genome_1, aligner=AlignmentGroup.ALIGNER.BWA) for position in xrange(self.first_variant_position, self.first_variant_position + self.num_variants): variant = Variant.objects.create( type=Variant.TYPE.TRANSITION, reference_genome=self.ref_genome_1, chromosome=self.chromosome, position=position, ref_value='A') variant.variantalternate_set.add( VariantAlternate.objects.create(variant=variant, alt_value='G')) vccd = VariantCallerCommonData.objects.create( variant=variant, source_dataset_id=1, alignment_group=alignment_group, data={}) VariantEvidence.objects.create(experiment_sample=self.sample_1, variant_caller_common_data=vccd, data={}) VariantToVariantSet.objects.create(variant=variant, variant_set=fake_variant_set) self.var_set1 = VariantSet.objects.create( reference_genome=self.ref_genome_1, label=VARIANTSET_1_LABEL) self.var_set2 = VariantSet.objects.create( reference_genome=self.ref_genome_1, label=VARIANTSET_2_LABEL)
def setUp(self): common_entities = create_common_entities() self.project = common_entities['project'] self.reference_genome = import_reference_genome_from_local_file( self.project, 'ref_genome', TEST_FASTA, 'fasta') self.experiment_sample = ExperimentSample.objects.create( project=self.project, label='sample1') copy_and_add_dataset_source(self.experiment_sample, Dataset.TYPE.FASTQ1, Dataset.TYPE.FASTQ1, TEST_FASTQ1) copy_and_add_dataset_source(self.experiment_sample, Dataset.TYPE.FASTQ2, Dataset.TYPE.FASTQ2, TEST_FASTQ2)
def setUp(self): """Override. """ self.common_entities = create_common_entities() self.ref_genome = self.common_entities['reference_genome']
def setUp(self): self.common_data = create_common_entities() self.project = self.common_data['project']
def setUp(self): self.common_entities = create_common_entities() self.cursor = connection.cursor()
def setUp(self): self.test_entities = create_common_entities() self.reference_genome = self.test_entities['reference_genome']
def setUp(self): self.common_data = create_common_entities() self.project = self.common_data['project'] self.reference_genome = import_reference_genome_from_local_file( self.project, 'ref_genome', TEST_FASTA, 'fasta')
def setUp(self): """Override. """ common_entities = create_common_entities() self.user = common_entities['user']
def test_simple(self): common_entities = create_common_entities() project = common_entities['project'] self.ref_genome_1 = common_entities['reference_genome'] self.chromosome = common_entities['chromosome'] self.sample_1 = ExperimentSample.objects.create( project=project, label=SAMPLE_1_LABEL) self.sample_2 = ExperimentSample.objects.create( project=project, label=SAMPLE_2_LABEL) alignment_group = AlignmentGroup.objects.create( label='Alignment 1', reference_genome=self.ref_genome_1, aligner=AlignmentGroup.ALIGNER.BWA) var_set_1 = VariantSet.objects.create( reference_genome=self.ref_genome_1, label=VARIANTSET_1_LABEL) variant = Variant.objects.create( type=Variant.TYPE.TRANSITION, reference_genome=self.ref_genome_1, chromosome=self.chromosome, position=100, ref_value='A') variant.variantalternate_set.add( VariantAlternate.objects.create( variant=variant, alt_value='G')) vtvs = VariantToVariantSet.objects.create( variant=variant, variant_set=var_set_1) vccd = VariantCallerCommonData.objects.create( variant=variant, source_dataset_id=1, alignment_group=alignment_group, data={}) # Add a VariantEvidence with no GT_TYPE. VariantEvidence.objects.create( experiment_sample=self.sample_1, variant_caller_common_data=vccd, data={}) self.assertEqual(0, vtvs.sample_variant_set_association.count()) # Now add a VariantEvidence that has GT_TYPE=2 and run # ensure_variant_set_consistency(). raw_sample_data_dict = { 'CALLED': True, 'GT_TYPE': 2, 'GT_BASES': 'G/G' } VariantEvidence.objects.create( experiment_sample=self.sample_2, variant_caller_common_data=vccd, data=raw_sample_data_dict) ensure_variant_set_consistency(var_set_1) self.assertEqual(1, vtvs.sample_variant_set_association.count())
def setUp(self): self.common_data = create_common_entities() self.project = self.common_data['project']
def setUp(self): self.common_entities = create_common_entities()
def test_add_variants_to_set_from_bed(self): common_entities = create_common_entities() project = common_entities['project'] self.ref_genome_1 = common_entities['reference_genome'] alignment_group = AlignmentGroup.objects.create( label='Alignment 1', reference_genome=self.ref_genome_1, aligner=AlignmentGroup.ALIGNER.BWA) (self.sample_1, created) = ExperimentSample.objects.get_or_create( project=project, label=SAMPLE_1_LABEL) sample_alignment = ExperimentSampleToAlignment.objects.create( alignment_group=alignment_group, experiment_sample=self.sample_1) # Create variants in the bed regions from best_test.bed for var_poor_map in range(20): variant = Variant.objects.create( type=Variant.TYPE.TRANSITION, reference_genome=self.ref_genome_1, chromosome=Chromosome.objects.get(reference_genome=self.ref_genome_1), position=random.randint(101,200), ref_value='A') vccd = VariantCallerCommonData.objects.create( variant=variant, source_dataset_id=1, alignment_group=alignment_group, data={} ) for var_no_cov in range(20): variant = Variant.objects.create( type=Variant.TYPE.TRANSITION, reference_genome=self.ref_genome_1, chromosome=Chromosome.objects.get(reference_genome=self.ref_genome_1), position=random.randint(301,400), ref_value='A') vccd = VariantCallerCommonData.objects.create( variant=variant, source_dataset_id=1, alignment_group=alignment_group, data={} ) variant = Variant.objects.create( type=Variant.TYPE.TRANSITION, reference_genome=self.ref_genome_1, chromosome=Chromosome.objects.get(reference_genome=self.ref_genome_1), position=random.randint(501,600), ref_value='A') vccd = VariantCallerCommonData.objects.create( variant=variant, source_dataset_id=1, alignment_group=alignment_group, data={} ) new_bed_path = copy_dataset_to_entity_data_dir( entity= sample_alignment, original_source_location= TEST_BED) bed_dataset = add_dataset_to_entity(sample_alignment, dataset_label= Dataset.TYPE.BED_CALLABLE_LOCI, dataset_type= Dataset.TYPE.BED_CALLABLE_LOCI, filesystem_location= new_bed_path) vs_to_v_map = add_variants_to_set_from_bed( sample_alignment, bed_dataset) variant_set_labels = set([vs.label for vs in vs_to_v_map.keys()]) self.assertEqual(set(['POOR_MAPPING_QUALITY', 'NO_COVERAGE']), variant_set_labels) for variant_set, variants in vs_to_v_map.items(): for v in variants: # POOR MAPPING QUAL should be from 101 to 200 if variant_set.label == 'POOR_MAPPING_QUALITY': self.assertTrue(v.position in pyinter.closedopen( 101, 200)) # NO COVERAGE should be from 301 to 400, 501 to 600 elif variant_set.label == 'NO_COVERAGE': self.assertTrue(v.position in pyinter.IntervalSet([ pyinter.closedopen(301,400), pyinter.closedopen(501,600)])) else: raise AssertionError( 'bad variant set %s made.' % variant_set.label)
def setUp(self): """Override. """ self.common_entities = create_common_entities()
def setUp(self): """Override. """ common_entities = create_common_entities() self.user = common_entities['user']
def setUp(self): self.common_entities = create_common_entities()
def setUp(self): """Override. """ self.common_entities = create_common_entities() self.project = self.common_entities['project']
def test_add_variants_to_set_from_bed(self): common_entities = create_common_entities() project = common_entities['project'] self.ref_genome_1 = common_entities['reference_genome'] alignment_group = AlignmentGroup.objects.create( label='Alignment 1', reference_genome=self.ref_genome_1, aligner=AlignmentGroup.ALIGNER.BWA) (self.sample_1, created) = ExperimentSample.objects.get_or_create( project=project, label=SAMPLE_1_LABEL) sample_alignment = ExperimentSampleToAlignment.objects.create( alignment_group=alignment_group, experiment_sample=self.sample_1) # Create variants in the bed regions from best_test.bed for var_poor_map in range(20): variant = Variant.objects.create( type=Variant.TYPE.TRANSITION, reference_genome=self.ref_genome_1, chromosome=Chromosome.objects.get( reference_genome=self.ref_genome_1), position=random.randint(101, 200), ref_value='A') vccd = VariantCallerCommonData.objects.create( variant=variant, source_dataset_id=1, alignment_group=alignment_group, data={}) for var_no_cov in range(20): variant = Variant.objects.create( type=Variant.TYPE.TRANSITION, reference_genome=self.ref_genome_1, chromosome=Chromosome.objects.get( reference_genome=self.ref_genome_1), position=random.randint(301, 400), ref_value='A') vccd = VariantCallerCommonData.objects.create( variant=variant, source_dataset_id=1, alignment_group=alignment_group, data={}) variant = Variant.objects.create( type=Variant.TYPE.TRANSITION, reference_genome=self.ref_genome_1, chromosome=Chromosome.objects.get( reference_genome=self.ref_genome_1), position=random.randint(501, 600), ref_value='A') vccd = VariantCallerCommonData.objects.create( variant=variant, source_dataset_id=1, alignment_group=alignment_group, data={}) new_bed_path = copy_dataset_to_entity_data_dir( entity=sample_alignment, original_source_location=TEST_BED) bed_dataset = add_dataset_to_entity( sample_alignment, dataset_label=Dataset.TYPE.BED_CALLABLE_LOCI, dataset_type=Dataset.TYPE.BED_CALLABLE_LOCI, filesystem_location=new_bed_path) vs_to_v_map = add_variants_to_set_from_bed(sample_alignment, bed_dataset) variant_set_labels = set([vs.label for vs in vs_to_v_map.keys()]) self.assertEqual(set(['POOR_MAPPING_QUALITY', 'NO_COVERAGE']), variant_set_labels) for variant_set, variants in vs_to_v_map.items(): for v in variants: # POOR MAPPING QUAL should be from 101 to 200 if variant_set.label == 'POOR_MAPPING_QUALITY': self.assertTrue(v.position in pyinter.closedopen(101, 200)) # NO COVERAGE should be from 301 to 400, 501 to 600 elif variant_set.label == 'NO_COVERAGE': self.assertTrue(v.position in pyinter.IntervalSet([ pyinter.closedopen(301, 400), pyinter.closedopen(501, 600) ])) else: raise AssertionError('bad variant set %s made.' % variant_set.label)
def setUp(self): self.test_entities = create_common_entities() self.reference_genome = self.test_entities['reference_genome']
def setUp(self): """Override. """ self.common_entities = create_common_entities() self.ref_genome = self.common_entities['reference_genome']
def setUp(self): """Override. """ self.common_entities = create_common_entities() self.project = self.common_entities['project']
def setUp(self): """Override. """ self.common_entities = create_common_entities()