Giter Club home page Giter Club logo

circular-string-linearization-problem's Introduction

circular-string-linearization-problem

This problem arises in chemical databases for circular molecules. Each molecule is represented by a circular string of chemical characters; to allow faster lookup and comparisons of molecules, one wants to store each circular string by a canonical linear string. A circular string of length n is a string in which the last character n -1 is considered to precede the first character 0. The circular string linearization problem for a string S of n characters is the following: Choose a place to cut the string S so that the resulting linear string is lexically smallest of all the n possible linear strings created by cutting S. For example, for circular string S=gcttc, we can get five linear strings: gcttc, cttcg, ttcgc, tcgct, cgctt. Of these cgctt is the lexically smallest one.

There are several approaches to solving this problem. One way to solve it using a suffix tree is to consider the doubled string SS, creating a suffix tree for it, and then searching in the tree for the lexicographically smallest substring of n characters.

Input/output specification:

python yourprogram.py stringinput

Given a circular DNA sequence S, the program should calculate the positions to cut S so that the resulting string is lexically smallest. For example, in the first sample input if you cut between positions 3 and 4, you will get the lexically smallest string cgctt. In the second sample input, you need to cut between first and last position to get it.

Sample Input: gcttc

Sample Output: 3,4

Sample Input: cgctt

Sample Output: 0,4

circular-string-linearization-problem's People

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.