Question

Please provide the general python code needed: Use regular expression to find all of the genes that meet the following c...

Please provide the general python code needed:

Use regular expression to find all of the genes that meet the following criteria. You just have to print out the number of matched genes to standard output (i.e. console).

a sequence that is between 10 to 50 bp that has no A or Ts.
any nucleotide repeated three times followed by any nucleotide repeated three times.
A one or more times, followed by T one or more times, followed by G one or more times, followed by C one or more times
one T followed by one A followed by five bases followed by one A followed by one T.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Please find the answers as below::

Note that for each, I am assuming we are checking only one end of the string, and thus, its corresponding pair would occur on the other end. Please accommodate any changes that the biology of the problem might require.

a) check for a length of 10 to 50 basepairs, that they do not comprise of A or T.

String checker::: [^AT]{10, 50}

This means that the string should not contain the characters A and T and must be of a length of 10 to 50 characters.  

Code:::

import re

txt = "GCGCGCCGGCGCGGCGCC"
x = re.search("[^AT]{10,50}", txt)

if (x):
print("YES! We have a match!")
else:
print("No match")

b) A nucleotide repeated thrice followed by a nucleotide repeated thrice.

String checker ::: (A|T|G|C){3}(A|T|G|C){3}

note that the problem does not mention that the two nucleotides must be different. Hence a repetition of G six times is also a valid string.

Code:::

import re

txt = "GCGCGCCGGCGCGGGCCCGCC"
x = re.search("(A|T|G|C){3}(A|T|G|C){3}", txt)

if (x):
print("YES! We have a match!")
else:
print("No match")

c) One or more instances of A then T then G then C

String checker ::: A+T+G+C+

Code :::

import re

txt = "ATGCC"
x = re.search("A+T+G+C+", txt)

if (x):
print("YES! We have a match!")
else:
print("No match")

d) TA followed by 5 bases followed by AT

String checker ::: TA.....AT

Code :::

import re

txt = "TA.....AT"
x = re.search("TAGGCGCATGGA", txt)

if (x):
print("YES! We have a match!")
else:
print("No match")

Hopefully, this is helpful.

Add a comment
Know the answer?
Add Answer to:
Please provide the general python code needed: Use regular expression to find all of the genes that meet the following c...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Preliminaries For this lab you will be working with regular expressions in Python. Various functions for...

    Preliminaries For this lab you will be working with regular expressions in Python. Various functions for working with regular expressions are available in the re module. Fortunately, Python makes it pretty easy to check if a string matches a particular pattern. At the top of the file we must import the re module: import re Then we can use the search() function to test whether a string matches a pattern. In the example below, the regular expression has been saved...

  • 1. Use a Regular Expression to define the set of all bit strings of one or...

    1. Use a Regular Expression to define the set of all bit strings of one or more 0's followed by only a 1. 2. Use a Regular Expression to define the set of all bit string of two or more symbols followed by three or more 0's. 3. Are these two grammars the same? a. S-> aSb|ab|λ b. S-> aAb|ab A->aAb|λ 4. Use the process of elimination to find the language of the following FA: (see picture for diagram) 5....

  • Python   #complete the following lines of code wherever indicated. 5 question 20 points a piece #you...

    Python   #complete the following lines of code wherever indicated. 5 question 20 points a piece #you may use your book and internet but no form of messaging or communication #QUESTION 1 #Read in the file exam_file.txt #Print to the console every other line #QUESTION 2 #Read in exam_file.txt #split file into words #write to a file called question2.out that contains 1 word per line (words can occur more than once) #QUESTION 3 # Print out all the Middle Initials in...

  • Python #complete the following lines of code wherever indicated. 5 question 20 points a piece #you...

    Python #complete the following lines of code wherever indicated. 5 question 20 points a piece #you may use your book and internet but no form of messaging or communication #QUESTION 1 #Read in the file exam_file.txt #Print to the console every other line #QUESTION 2 #Read in exam_file.txt #split file into words #write to a file called question2.out that contains 1 word per line (words can occur more than once) #QUESTION 3 # Print out all the Middle Initials in...

  • Given java code is below, please use it! import java.util.Scanner; public class LA2a {      ...

    Given java code is below, please use it! import java.util.Scanner; public class LA2a {       /**    * Number of digits in a valid value sequence    */    public static final int SEQ_DIGITS = 10;       /**    * Error for an invalid sequence    * (not correct number of characters    * or not made only of digits)    */    public static final String ERR_SEQ = "Invalid sequence";       /**    * Error for...

  • You need not run Python programs on a computer in solving the following problems. Place your...

    You need not run Python programs on a computer in solving the following problems. Place your answers into separate "text" files using the names indicated on each problem. Please create your text files using the same text editor that you use for your .py files. Answer submitted in another file format such as .doc, .pages, .rtf, or.pdf will lose least one point per problem! [1] 3 points Use file math.txt What is the precise output from the following code? bar...

  • please use python and provide run result, thank you! click on pic to make it bigger...

    please use python and provide run result, thank you! click on pic to make it bigger For this assignment you will have to investigate the use of the Python random library's random generator function, random.randrange(stop), randrange produces a random integer in the range of 0 to stop-1. You will need to import random at the top of your program. You can find this in the text or using the online resources given in the lectures A Slot Machine Simulation Understand...

  • Please develop the following code using C programming and using the specific functions, instructi...

    Please develop the following code using C programming and using the specific functions, instructions and format given below. Again please use the functions given especially. Also don't copy any existing solution please write your own code. This is the first part of a series of two labs (Lab 7 and Lab 8) that will complete an implementation for a board-type game called Reversi (also called Othello). The goal of this lab is to write code that sets up the input...

  • can u tell me if these answers are correct please!??!!! Choose the best answer for the...

    can u tell me if these answers are correct please!??!!! Choose the best answer for the following questions. Place your answer on the line. If your answer is not on the line.it does not count 1 Mender's discovery that characteristics are inherited due to the transmission of hereditary factors resulted from his (1) dissections to determine how fertilization occurs in pea plants (2analysis of the offspring produced from many pea plant crosses (3) careful microscopic examinations of genes and chromosomes...

  • The following guidelines outline the basic template for a robot vacuum cleaner game. The game must be implemented in c programming language. It mimics a robotic vacuum cleaner. The code must only use...

    The following guidelines outline the basic template for a robot vacuum cleaner game. The game must be implemented in c programming language. It mimics a robotic vacuum cleaner. The code must only use the following libraries: #include <math.h> #include <stdlib.h> #include <string.h> #include <limits.h> and any .graphics and .timers libraries. The guidelines are outlined as follows: Terminal Set-up: you may assume that the terminal will be quite large, for example, on the order of 150×50, or more. Status Display: The...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT