Skip to content

Conversation

@decareano
Copy link

The script "mitolin_split.py" will generate two new fasta.eg files with only ChrM data.

  1. chrMchr1New-1.fasta.eg
  2. chrMchr1New-2.fasta.eg

Copy link
Contributor

@Deena-B Deena-B left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi Marcello,
This is great! Thanks for taking the time to write this code and re-factor it.
I have some questions:

  1. Does open("chrMchr1New-"+str(x)+".fasta.eg", 'w')
    also create a file or did you have to create them, then open them in your script?

  2. Are opened files automatically read one line at a time?

  3. I'm confused about the two uses of '/n'.
    First you seem to strip it: mylines.append(a_line.rstrip('\n'))
    Then, does this line add it?: writer.writelines("%s\n" % i for i in mylines)
    If so, why strip it and add it back?

  4. Would you also please explain what the letters i stand for in the string formatting line below?
    writer.writelines("%s\n" % i for i in mylines)

Thanks so much,
Deena

@Deena-B
Copy link
Contributor

Deena-B commented Aug 1, 2019

Hi Marcello,
Please see the note below "Rebasing the commits of this branch on top of the base branch cannot be performed automatically due to conflicts encountered while reapplying the individual commits from the head branch."

From reading the "command line instructions" it looks like you have to do the rebase "from your project repository". Please give it a try and message me to let me know how it went.

Cheers,
Deena

@decareano
Copy link
Author

Hi Deena,

  1. Does open("chrMchr1New-"+str(x)+".fasta.eg", 'w')
    also create a file or did you have to create them, then open them in your script?

    I am using the loop to iterate through the files you provided. it then writes the results of the parsing to a new file("chrMchr1New-"+str(x)+".fasta.eg", 'w')

  2. Are opened files automatically read one line at a time?
    In this case, I convert them to a list and append the lines (one by one to the list)

  3. I'm confused about the two uses of '/n'.
    First you seem to strip it: mylines.append(a_line.rstrip('\n'))
    You are right, don't needed here. Removed. rstrip with no args by default will remove the whitespace I think.

    Then, does this line add it?: writer.writelines("%s\n" % i for i in mylines)
    If so, why strip it and add it back?
    I use it here for neater formatting purposes. If not, you get the sequences all bunched up.

  4. Would you also please explain what the letters i stand for in the string formatting line below?
    writer.writelines("%s\n" % i for i in mylines)
    writelines() iterates over this sequence of strings (i) and writes every item.
    https://stackoverflow.com/questions/12377473/python-write-versus-writelines-and-concatenated-strings. For further info

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants