Index Generator API

API operations on pools.

class index_generator.views.GeneratorIndexTypeViewSet(**kwargs)[source]

Bases: index_generator.views.MoveOtherMixin, rest_framework.viewsets.ReadOnlyModelViewSet

Get the list of index types.

queryset
serializer_class

alias of IndexTypeSerializer

class index_generator.views.IndexGeneratorViewSet(**kwargs)[source]

Bases: rest_framework.viewsets.ViewSet, common.mixins.LibrarySampleMultiEditMixin

generate_indices(request)[source]

Generate indices for given libraries and samples.

library_model

alias of Library

library_serializer

alias of IndexGeneratorLibrarySerializer

list(request)[source]

Get the list of libraries and samples ready for pooling.

permission_classes = [<class 'rest_framework.permissions.IsAdminUser'>]
sample_model

alias of Sample

sample_serializer

alias of IndexGeneratorSampleSerializer

save_pool(request)[source]

Create a pool after generating indices, add libraries and “converted” samples to it, update the pool size, and create a Library Preparation object and a Pooling object for each added library/sample.

class index_generator.views.MoveOtherMixin[source]

Bases: object

Move the Other option to the end of the returning list.

list(request)[source]
class index_generator.views.PoolSizeViewSet(**kwargs)[source]

Bases: rest_framework.viewsets.ReadOnlyModelViewSet

Get the list of pool sizes.

queryset
serializer_class

alias of PoolSizeSerializer

class index_generator.index_generator.IndexRegistry(mode, index_types, start_coord='A1', direction='right')[source]

Bases: object

Class for storing fetched and sorted indices i7/i5 and index pairs.

static create_index_dict(format='', index_type='', read_type='', prefix='', number='', index='', coordinate='', is_library=False)[source]
fetch_indices(index_type)[source]

Fetch indices i7 and i5 for a given index type.

fetch_pairs(index_type, char_coord, num_coord, direction)[source]

Fetch index pairs (Index i7 + Index i5) for a given index type, start coordinate, and direction.

get_diagonal(index_pairs)[source]

Sort index pairs diagonally.

get_indices(index_type_id, index_group)[source]

Return a list of indices for a given index type id and index group.

get_pairs(index_type_id)[source]

Return a list of index pairs for a given index type id.

static split_coordinate(coordinate)[source]

Split a submitted coordinate into a character and a numeric parts.

to_list(format, index_type, read_type, indices)[source]

Return a list of index dicts.

class index_generator.index_generator.IndexGenerator(library_ids, sample_ids, start_coord, direction)[source]

Bases: object

Main class that fetches provided libraries and samples, checks the compatibility of their index types, generates indices, and assigns them to the libraries and samples.

MAX_ATTEMPTS = 30
MAX_RANDOM_SAMPLES = 5
add_libraries_to_result()[source]

Add all libraries directly to the result.

calculate_color_distribution(indices, sequencing_depths, sample)[source]
calculate_scores(current_sample, current_converted_index, current_color_distribution, total_depth)[source]

Calculate the scores for a given sample.

Score is an absolute difference between the sequencing depths of the two indices divided by the total sequencing depth (in %).

The ideal score is 0.0 (50% green and 50% red), an acceptable score is 60.0 (80%/20% or 20%/80%).

If the score > 60%, then the indices are not compatible.

static convert_index(index)[source]

Convert A/C into R (red) and T into G (green).

static create_result_dict(obj, index_i7, index_i5)[source]
find_index(sample, index_group, current_indices, depths)[source]

Helper function for find_indices().

find_indices(samples, depths, index_group, init_indices)[source]

Generate indices for given samples and index group (I7/I5).

find_pair(sample, depths, current_pairs)[source]

Helper function for find_pairs().

find_pairs(samples, depths, init_pairs)[source]

Generate index pairs for given samples.

find_pairs_fixed(plate_samples, init_index_pairs)[source]

Return subsequent index pairs from the Index Registry starting from the first one.

find_random(sample)[source]

Find a pair of random indices I7/I5 for a given sample.

format = ''
generate()[source]

Main method that generates indices.

index_length = 0
index_registry = None
libraries = None
mode = ''
num_libraries = 0
num_samples = 0
result

Construct a list of all records and their indices.

samples = None
static sort_indices(indices)[source]

Sort indices I7/I5 by ID.

static sort_pairs(pairs)[source]

Sort index pairs (only by Index I7 ID).

static sort_sequencing_depths(depths)[source]

Sort sequencing depths to improve the result.

validate_index_types(records)[source]

Check the compatibility of provided libraries and samples.