#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    2
    Rep Power
    0

    Need help making this program please ASAP!!


    Step 1: Create an empty list (of dictionaries)
    Step 2: Prompt the user for the scoring matrix file name
    Step 3: Open the file and read the contents as a list of strings. Ignore the comment lines
    Step 4: When you reach a line that doesn’t start with '#' read in the amino acid symbols and split them into your keys for your dictionary
    Step 5: Read in the rest of the lines one at a time. For each line:
    Step 5a. Slice off the first character (amino acid).
    Step 5b. For the rest of the string split into individual numbers and convert to a list of integers (use a list comprehension). This is your data for your dictionary.
    Step 5c. Zip the keys and data together and convert into a dictionary.
    Step 5d. Add the dictionary to the list of dictionaries
    Step 6: After you’ve read all lines, create the dictionary of dictionaries by zipping the keys and the list of dictionaries and convert into a dictionary.
  2. #2
  3. No Profile Picture
    Lost in code
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 2004
    Posts
    8,316
    Rep Power
    7170
    Good luck with that one; I recommend posting the code you've started writing for it and the questions you ran into when you got stuck.
    PHP FAQ

    Originally Posted by Spad
    Ah USB, the only rectangular connector where you have to make 3 attempts before you get it the right way around
  4. #3
  5. Contributing User
    Devshed Demi-God (4500 - 4999 posts)

    Join Date
    Aug 2011
    Posts
    4,966
    Rep Power
    481
    Step 1: Create an empty list (of dictionaries)
    If the list is empty, how would it contain dictionaries?

    In addition to posting an effort please also show sample input with expected output. If it happens that you solve the problem then you need not post again.
    [code]Code tags[/code] are essential for python code and Makefiles!
  6. #4
  7. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    2
    Rep Power
    0

    What i have so far


    keys = ['', '', '']

    name1 = ['', '', '']
    name2 = ['', '', '']

    dictList = []
    dictList.append(dict(zip(keys, name1)))
    dictList.append(dict(zip(keys, name2)))

    print dictList
    for item in dictList:
    print ' '.join([item[key] for key in keys])

    prot_filename = raw_input("Enter filename: ")
    prot_file = open(prot_filename, 'r')
    aa_seq = prot_file.read()
    prot_file.close()

    for line in open("file"):
    li=line.strip()
    if not li.startswith("#"):
    print line.rstrip()

    for sequence in message.split(" "):
    if sequence.startswith('<')
    sequence = sequence[1:-1]
  8. #5
  9. JavaScript is not spelt java
    Devshed Novice (500 - 999 posts)

    Join Date
    Feb 2011
    Location
    Landan, England
    Posts
    743
    Rep Power
    165
    You need to wrap your code in code-tags - this is particularly important for Python (see the previous poster's signature).

    Your last line could/should be

    Code:
    sequence = sequence[1:]
    although I assume it still works with the -1.
    Last edited by AndrewSW; November 14th, 2012 at 07:57 AM.

IMN logo majestic logo threadwatch logo seochat tools logo