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

  • SEARCH
  • Home
  • 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 8826445
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T07:08:24+00:00 2026-06-14T07:08:24+00:00

I appreciate that this task is probably a bit ambitious given my level (or

  • 0

I appreciate that this task is probably a bit ambitious given my level (or lack) of knowledge, but still.

I have a list of 16 character strings, about 3000 items long, where each character denotes another list of numbers. Not sure if I’m making that clear; what it actually is a list of 16-amino acid long peptides, where each of the amino acids (1 of 20) is representable by 5 numbers.

I want to iterate through that list (of peptides), and then for each character (amino acid) add the relevant 5 numbers (Atchley factors, if you’re interested) to an array, making a 3 dimensional array, where my axes are: instance of peptide (3000) x amino acid within that peptide (16) x factors (5).

I’m incredibly out of my depth, so I’m not sure if what I’ve got is useful is helpful, but here it is (using numpy):

array = np.empty(shape=(len(peptides),16,5)

for i in peptides:

    for j in str(i):

(and at this point I tried a bunch of different things as I trawled the forums, ending with something a little like this, but I’m sure I’ve missed even what I was aiming for here)

    if j == 'A':    
            L16Afctrs = np.append([-0.59145974, -1.30209266, -0.7330651, 1.5703918, -0.14550842], axis=1)
    elif j == 'C':
            L16Afctrs = np.append([-1.34267179, 0.46542300, -0.8620345, -1.0200786, -0.25516894], axis=1)
    ...
    elif j == 'Y':
            L16Afctrs = np.append([0.25999617, 0.82992312, 3.0973596, -0.8380164, 1.51150958], axis=1)

Like I say, I’m honestly struggling, any help would be much appreciated.

Edit: clarification (hopefully)

I have a list of around 3000 different 16 character strings, where each character in those strings denotes a further 5 numbers.

I want to generate a 3 dimensional array or structure, whereby I can (eventually) plot those 5 numbers for a given position across all 3000 strings, by looking across a given plane in the 3 dimensional array (where the dimensions I envisage are; original string x 16 characters x 5 factors).

I’m currently in the process of making a dictionary of the different characters, relating to the post from @Winston, then trying to fold that into a 3d array.

Edit 2: Success!

Winston’s fix works beautifully!

  • 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-06-14T07:08:25+00:00Added an answer on June 14, 2026 at 7:08 am

    Store your data in a dictionary:

    DATA = {
        'A' : numpy.array([-0.59145974, -1.30209266, -0.7330651, 1.5703918, -0.14550842]),
        'B' : numpy.array([-1.34267179, 0.46542300, -0.8620345, -1.0200786, -0.25516894]),
        'D' : numpy.array([1.05015062, 0.30242411, -3.6559147, -0.2590236, -3.24176791])
        ...
    }
    

    Use a python list comprehension to build a list of all those, and then have numpy convert that list into a numpy array

    counters = numpy.array([DATA[letter] for peptide in peptides for letter in peptide])
    

    Reshape the array into your 3D dimensions, since the last step will have 2D arrays

    counters = counters.reshape( len(peptides), 16, 5 )
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I Have been given this simple task , I have this list where i
I am new to Qt , I have been given this task where i
Basically, I misread this but would still really appreciate some assurance. I recently came
(Let me begin by saying that a) I appreciate this is the wrong place
UPDATE : I do appreciate don't want that, want this instead suggestions. They are
I love Jenkins and appreciate that it is an active project. Still, I don't
Please see below: I tried using Absolute layout, but that's deprecated. I appreciate your
I have a task that generates java sources and a set of jars from
I have a scheduled task that runs a script on a regular basis (every
I'm new to PHP so this is probably a super trivial task: Right now

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.