{"action":"created","issue":{"url":"https://api.github.com/repos/biopython/biopython/issues/939","repository_url":"https://api.github.com/repos/biopython/biopython","labels_url":"https://api.github.com/repos/biopython/biopython/issues/939/labels{/name}","comments_url":"https://api.github.com/repos/biopython/biopython/issues/939/comments","events_url":"https://api.github.com/repos/biopython/biopython/issues/939/events","html_url":"https://github.com/biopython/biopython/issues/939","id":177918136,"number":939,"title":"How to split a very large .fasta file into roughly equally sized files?","user":{"login":"dmenning","id":13802735,"avatar_url":"https://avatars.githubusercontent.com/u/13802735?v=3","gravatar_id":"","url":"https://api.github.com/users/dmenning","html_url":"https://github.com/dmenning","followers_url":"https://api.github.com/users/dmenning/followers","following_url":"https://api.github.com/users/dmenning/following{/other_user}","gists_url":"https://api.github.com/users/dmenning/gists{/gist_id}","starred_url":"https://api.github.com/users/dmenning/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dmenning/subscriptions","organizations_url":"https://api.github.com/users/dmenning/orgs","repos_url":"https://api.github.com/users/dmenning/repos","events_url":"https://api.github.com/users/dmenning/events{/privacy}","received_events_url":"https://api.github.com/users/dmenning/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":7,"created_at":"2016-09-19T22:46:19Z","updated_at":"2016-09-23T11:20:02Z","closed_at":"2016-09-23T11:20:02Z","body":"I do a lot of primer design and checking so I have written scripts to parse through .fasta files.  In some cases these are fairly large 10+gb.  I would like to break these up into smaller more manageable files.  I was looking for a method to break up large files by size and came along this:\r\nhttp://stackoverflow.com/questions/291740/how-do-i-split-a-huge-text-file-in-python\r\n```\r\n    import logging.handlers\r\n    log = logging.getLogger()\r\n    fh = logging.handlers.RotatingFileHandler(\"verylarge.fasta\", \r\n        maxBytes=2**20*100, backupCount=100) \r\n    log.addHandler(fh)\r\n    log.setLevel(logging.INFO)\r\n    f = open(\"D://biglog.txt\")\r\n    while True:\r\n        log.info(f.readline().strip())\r\n```\r\n\r\nMy question is, can I use this to break up a large .fasta file into smaller, equally sized files?  I think it would just read the text and possibly cut off the DNA sequence before finishing if it got close to the max size and am not sure how to handle this using Biopython.  Is there a way to get a running output file size, current size of data to be written, then if there is enough room in the file to write the data, and move on?\r\n\r\nThanks\r\n\r\n  Damian"},"comment":{"url":"https://api.github.com/repos/biopython/biopython/issues/comments/249166528","html_url":"https://github.com/biopython/biopython/issues/939#issuecomment-249166528","issue_url":"https://api.github.com/repos/biopython/biopython/issues/939","id":249166528,"user":{"login":"peterjc","id":63959,"avatar_url":"https://avatars.githubusercontent.com/u/63959?v=3","gravatar_id":"","url":"https://api.github.com/users/peterjc","html_url":"https://github.com/peterjc","followers_url":"https://api.github.com/users/peterjc/followers","following_url":"https://api.github.com/users/peterjc/following{/other_user}","gists_url":"https://api.github.com/users/peterjc/gists{/gist_id}","starred_url":"https://api.github.com/users/peterjc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/peterjc/subscriptions","organizations_url":"https://api.github.com/users/peterjc/orgs","repos_url":"https://api.github.com/users/peterjc/repos","events_url":"https://api.github.com/users/peterjc/events{/privacy}","received_events_url":"https://api.github.com/users/peterjc/received_events","type":"User","site_admin":false},"created_at":"2016-09-23T11:20:02Z","updated_at":"2016-09-23T11:20:02Z","body":"I was going to say since you only use strings and don't care about line wrapping in the output, use:\r\n\r\n```\r\nfrom Bio.SeqIO.FastaIO import SimpleFastaParser\r\nfor title, seq in SimpleFastaParser(handle):\r\n    # etc\r\n```\r\n\r\nAnyway, glad you've got something working."}}
{"actor":{"display_login":"peterjc"}}