Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7589799
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T20:15:01+00:00 2026-05-30T20:15:01+00:00

I am having difficulty getting this scoring function to work. The objective of my

  • 0

I am having difficulty getting this scoring function to work. The objective of my program is to make a t x n matrix and find a consensus sequence.

I keep getting a error :

TypeError: ‘int’ object is not subscriptable.

Any help would be appreciated.

  def Score(s, i, l, dna):
    t = len(dna) # t = number of dna sequences

    # Step 1: Extract the alignment corresponding to starting positions in s

    alignment = []
    for j in range(0, i):
        alignment.append(dna[j][s[j]:s[j]+l])

    # Step 2: Create the corresponding profile matrix

    profile = [[],[],[],[]]      # prepare an empty 4 x l profile matrix first
    for j in range(0, 4):
        profile[j] = [0] * l

    for c in range(0, l):        # for each column number c
        for r in range(0, i):     # for each row number r in column c
            if alignment[r][c] == 'a':
                profile[0][c] = profile[0][c] + 1
            elif alignment[r][c] == 't':
                profile[1][c] = profile[1][c] + 1
            elif alignment[r][c] == 'g':
                profile[2][c] = profile[2][c] + 1
            else:
                profile[3][c] = profile[3][c] + 1


    # Step 3: Compute the score from the profile matrix

    score = 0
    for c in range(0, l):
        score = score + max([profile[0][c], profile[1][c], profile[2][c], profile[3][c]])

    return score
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T20:15:02+00:00Added an answer on May 30, 2026 at 8:15 pm

    Is your variable dna a dictionary,
    if so use def Score(s, i, l, **dna)

    If it is int variable, you can’t access it as dna[j][s[j]:s[j]+l]

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm following a tutorial on php, and am having difficulty getting this to work.
I'm having some difficulty getting this script to execute properly. The create_rss function does
I’m having a bit of difficulty getting this to work – and to be
I am having difficulty getting the create function of backbone.js to work. My main
I'm having difficulty getting XQuery to work. I downloaded Saxon-HE 9.2. It seems to
I'm having a lot of difficulty getting strophe's 'attach()' function working. I am working
I'm having difficulty getting the Model Binder to work. I thought it was the
I'm new to Regular Expressions and am having difficulty getting patterns that I find
I'm having difficulty getting the awk command inside a bash script to work. The
I'm having real difficulty getting the eclipselink.join-fetch hint to work in glassfish. I have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.