1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
vovangra [49]
3 years ago
14

1. Extract title Write a function extract_title that takes one parameter, the filename of a GenBank formatted file, and returns

a string with the title of the dataset. The title is what follows the first occurrence of the tag "TITLE" and goes all the way before the tag "JOURNAL". Be aware that the title might extend in more than one lines; i

Computers and Technology
1 answer:
trapecia [35]3 years ago
6 0

Answer:

def extract_title(file):

   import re

   a =''

   with open(file,'r') as file:

       for line in file:

           a += line

       m = re.search("^(TITLE)(.*?)(JOURNAL)", a, re.M + re.S)

       print(m.groups()[1])

extract_title('new.txt')

Explanation:

The programming language used is python 3.

The function is first defined and the regular expression module is imported.

A variable is initialized to an empty string that will hold the content of the GenBank formatted file.

The file is opened and every line in the file is assigned to the string variable. The WITH statement allows files to be closed automatically.

Regular expression is used to capture all the files between TITLE and JOURNAL in a group.

The group is printed and the function is called.

I have attached a picture of the code in action.

You might be interested in
Which is a feature of a strong thesis statement?
inessss [21]
A strong thesis statement should answer, but not elaborate on your opinion, or the facts of the central question.
6 0
3 years ago
A unit of measurement that describe the rate that electricity flows through a wire is an
Savatey [412]
AMPERE - a unit of measure for the flow of the current in a circut
8 0
3 years ago
Which of the following is NOT a rule you should follow when creating a presentation?
Nataly_w [17]
False, Write in full sentences and paragraphs on your slides - It is your presentation! Make it how you want to 
8 0
3 years ago
The file includes 4993 tweets including the keyword 'election'. Each tweet is represented in a separate line. Write a program to
Likurg_2 [28]

Answer:

import re

with open("../../Downloads/Tweets.txt","r", encoding="utf-8") as tweets:

   myfile = tweets.readlines()

   for item in myfile:

       item = item.rstrip()

       mylist = re.findall("^RT (.*) ", item)

       if len(mylist) !=0:

           for line in mylist:

               if line.count("#") >=1:

                   ln = line.split("#")

                   dm = ln[1]

                   print(f"#{dm}")

Explanation:

The python source code filters the document file "Tweets" to return all tweets with a hashtag flag, discarding the rest.

7 0
2 years ago
Which of formula contains an absolute cell reference?
svet-max [94.6K]
Which formula contains an absolute cell reference? =SUM($B$7:$B$9)
3 0
2 years ago
Other questions:
  • Aubrey didnt like to use graphics or images on her slides. She preferred to use only a title for her slides and bullet-poinged t
    14·2 answers
  • In addition to not parking where signs prohibit it, you should never park __________________.
    12·1 answer
  • "The pkill command terminates _________."
    14·1 answer
  • When transporting data from real-time applications, such as streaming audio and video, which field in the ipv6 header can be use
    12·1 answer
  • (EASY 15 POINTS) What are two indications in a browser that a secure connection is being used?
    6·1 answer
  • This program will store roster and rating information for a soccer team. Coaches rate players during tryouts to ensure a balance
    7·1 answer
  • Assembly (Procedure and Conditional Processing). For the following program, what are outputs for register EAX, EBX, ECX, and EDX
    11·1 answer
  • I need help I have questions I need answers in coding html,css,js and python.Fast
    7·1 answer
  • Assume you are using the text's array-based queue and have just instantiated a queue of capacity 10. You enqueue 5 elements and
    13·1 answer
  • Analog computers are general purpose computers : true ? or false ?​
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!