Ejemplo n.º 1
0
    def handle(self, **options):
        seq_starter = (LibrarySequencing.objects.select_related(
            'source_stock', 'source_stock__intended_clone'))

        # Categorize all sequences by blat results and intended clone
        seqs = seq_starter.all()
        seqs_blat = categorize_sequences_by_blat_results(seqs)
        self.print_categories('ALL SEQUENCES', seqs_blat)

        # Categorize sequences that have any SUP score
        any_suppression = get_positives_any_worm('SUP', 2,
                                                 shows_any_suppression)
        seqs_any_sup = seq_starter.filter(source_stock__in=any_suppression)
        seqs_any_sup_blat = categorize_sequences_by_blat_results(seqs_any_sup)
        self.print_categories('SEQUENCES CORRESPONDING TO ANY SUP '
                              'SCORES', seqs_any_sup_blat)

        # Categorize sequences for SUP percentage-criteria positives
        positives = get_positives_any_worm('SUP', 2,
                                           passes_sup_secondary_percent)
        seqs_pos = seq_starter.filter(source_stock__in=positives)
        seqs_pos_blat = categorize_sequences_by_blat_results(seqs_pos)
        self.print_categories(
            'SEQUENCES CORRESPONDING TO SUP SECONDARY '
            'PERCENT POSITIVES ONLY', seqs_pos_blat)

        # Categorize sequences for SUP high-confidence positives
        high_conf = get_positives_any_worm('SUP', 2,
                                           passes_sup_secondary_stringent)
        seqs_high = seq_starter.filter(source_stock__in=high_conf)
        seqs_high_blat = categorize_sequences_by_blat_results(seqs_high)
        self.print_categories(
            'SEQUENCES CORRESPONDING TO SUP SECONDARY '
            'STRINGENT POSITIVES ONLY', seqs_high_blat)
    def handle(self, **options):
        seq_starter = LibrarySequencing.objects.select_related("source_stock", "source_stock__intended_clone")

        # Categorize all sequences by blat results and intended clone
        seqs = seq_starter.all()
        seqs_blat = categorize_sequences_by_blat_results(seqs)
        self.print_categories("ALL SEQUENCES", seqs_blat)

        # Categorize sequences that have any SUP score
        any_suppression = get_positives_any_worm("SUP", 2, shows_any_suppression)
        seqs_any_sup = seq_starter.filter(source_stock__in=any_suppression)
        seqs_any_sup_blat = categorize_sequences_by_blat_results(seqs_any_sup)
        self.print_categories("SEQUENCES CORRESPONDING TO ANY SUP " "SCORES", seqs_any_sup_blat)

        # Categorize sequences for SUP percentage-criteria positives
        positives = get_positives_any_worm("SUP", 2, passes_sup_secondary_percent)
        seqs_pos = seq_starter.filter(source_stock__in=positives)
        seqs_pos_blat = categorize_sequences_by_blat_results(seqs_pos)
        self.print_categories("SEQUENCES CORRESPONDING TO SUP SECONDARY " "PERCENT POSITIVES ONLY", seqs_pos_blat)

        # Categorize sequences for SUP high-confidence positives
        high_conf = get_positives_any_worm("SUP", 2, passes_sup_secondary_stringent)
        seqs_high = seq_starter.filter(source_stock__in=high_conf)
        seqs_high_blat = categorize_sequences_by_blat_results(seqs_high)
        self.print_categories("SEQUENCES CORRESPONDING TO SUP SECONDARY " "STRINGENT POSITIVES ONLY", seqs_high_blat)
Ejemplo n.º 3
0
    def handle(self, **options):
        positives = get_positives_any_worm('SUP', 2, criteria)

        seqs = (LibrarySequencing.objects
                .filter(source_stock__in=positives)
                .select_related('source_stock',
                                'source_stock__intended_clone'))
        categorized_seqs = categorize_sequences_by_blat_results(seqs)

        stocks_to_resequence = []
        for category, values in categorized_seqs.items():
            if _should_be_redone(category):
                stocks_to_resequence.extend(
                    [x.source_stock for x in values])

        stocks_to_resequence = sorted(stocks_to_resequence,
                                      key=lambda stock: stock.id)

        assigned = assign_to_plates(
            stocks_to_resequence, vertical=True,
            empties_per_plate=options['empties_per_plate'])
        rows = get_plate_assignment_rows(assigned)

        # Write output
        self.stdout.write('source_plate,source_well,'
                          'destination_plate,destination_well')
        for row in rows:
            destination_plate = get_destination_plate(
                row[0], options['first_plate_number'])
            destination_well = row[1]
            source = row[2]

            if hasattr(source, 'plate'):
                source_plate = source.plate
            else:
                source_plate = None

            if hasattr(source, 'well'):
                source_well = source.well
            else:
                source_well = None

            self.stdout.write('{},{},{},{}'.format(
                source_plate, source_well,
                destination_plate, destination_well))
Ejemplo n.º 4
0
    def handle(self, **options):
        if options['summary']:
            summary_mode = True
        else:
            summary_mode = False

        # Categorize sequences corresponding to high confidence positives
        seqs = (LibrarySequencing.objects
                .select_related('source_stock',
                                'source_stock__intended_clone'))
        seqs_blat = categorize_sequences_by_blat_results(seqs)

        # Get set of "verified" wells (for now, just those for which the top
        # BLAT hit is an amplicon for the intended clone)
        verified = set(x.source_stock for x in seqs_blat[1])

        # Get all SUP worm strains
        worms = WormStrain.objects.exclude(
            restrictive_temperature__isnull=True)

        verified_doublecheck = set()
        num_interactions_by_well = 0
        num_interactions_by_clone = 0

        # For each worm, find the intersection of verified positives,
        # and add to the list of interactions
        w = {}
        for worm in worms:
            positives = worm.get_positives('SUP', 2,
                                           passes_sup_secondary_stringent)

            pos_verified = positives.intersection(verified)

            verified_doublecheck.update(pos_verified)
            num_interactions_by_well += len(pos_verified)

            pos_verified_clones = set()
            for well in pos_verified:
                clone = well.intended_clone_id
                if clone not in pos_verified:
                    pos_verified_clones.add(clone)

            num_interactions_by_clone += len(pos_verified_clones)
            w[worm] = pos_verified_clones

        if summary_mode:
            self.stdout.write('{} library wells both positive and verified\n'
                              '{} interactions by well\n'
                              '{} interactions by clone'
                              .format(len(verified_doublecheck),
                                      num_interactions_by_well,
                                      num_interactions_by_clone))

            self.stdout.write('Breakdown by worm:')
            for worm in sorted(w):
                self.stdout.write('\t{}: {}'.format(worm.gene, len(w[worm])))

        else:
            for worm in sorted(w):
                for clone in sorted(w[worm]):
                    self.stdout.write('{},{}'.format(worm.gene, clone))