15 votes
Accepted

Count the occurence of nucleobases in DNA string

Your code is fine and readable from a C/Java perspective. I don't think it's particularly Ruby-ic to use return statements. Just put ...
Barry's user avatar
  • 18.4k
13 votes

Filter out ambiguous bases from a DNA sequence

Perhaps there aren't enough test cases here, because I don't see why you can't just use: ...
Kraigolas's user avatar
  • 917
11 votes
Accepted

Simple program to split DNA sequences based on ambiguous content

Well one simple change will make it do lines in groups of four. ...
Martin York's user avatar
  • 94.6k
11 votes
Accepted

Counting relevant entries in a large bioinformatics file

In order to speed this up, you'll need to avoid as many string creation operations as possible, because they are expensive. Especially the split operation is expensive. Not only does this create many ...
RoToRa's user avatar
  • 11k
11 votes
Accepted

Implementing a DNA codon table in C

An array of char* is not a great data structure for storing AA or codon sequence data. A pointer takes 4 or 8 bytes per codon, but there are only 64 possible ...
Peter Cordes's user avatar
  • 3,266
10 votes
Accepted

A simple C++ class for packing DNA strings

static std::string&& dna_to_upper_case(std::string& unpacked_dna_sequence). That's wrong. It returns a dangling reference. You can't return an rvalue ...
kraskevich's user avatar
  • 5,580
10 votes

Counting relevant entries in a large bioinformatics file

If you are in for raw performance, try to avoid repeating potentially cost-intensive operations. In this case, you split the lines twice with the same parameter, which repeatedly applies a regular ...
mtj's user avatar
  • 4,802
10 votes
Accepted

Counting the occurrences of certain amino-acids in a file

Add functions Everything is currently in the global namespace, you can add a few functions to split up the code and make it more readable. You could use a ...
Ludisposed's user avatar
  • 11.5k
9 votes

Translate nucleic acid sequence into its corresponding amino acid sequence

This covers an interesting topic. Great work! Because I am unfamiliar with this area, I utilized your unit testing to ensure changes I make did not break functionality. If they do, I apologize and ...
esote's user avatar
  • 3,770
8 votes

Count the occurence of nucleobases in DNA string

I've make small research on your question. My first idea was: def countACGT(str) str.chars.sort.join.scan(/A+|C+|G+|T+/).map(&:length) end Then I've write ...
Sergii K's user avatar
  • 666
8 votes
Accepted

Finding roughly matching genome sequences in Python dictionary

You need a faster search method You are comparing every entry in duplexDict directly with every entry in duplexDict. This means ...
Ryan Mills's user avatar
  • 1,010
8 votes

A simple C++ class for packing DNA strings

First things first: Undefined behavior Kraskevich pointed at the most obvious one. Yet, there is one more (although it will work on X86, from what I've been told). Basically, do not pass chars ...
Incomputable's user avatar
  • 9,424
8 votes

FASTA-to-tsv conversion script

Welcome to Code Review! I'll add to the other answer from Reinderien. PEP-8 In python, it is common (and recommended) to follow the PEP-8 style guide for writing clean, maintainable and consistent ...
hjpotter92's user avatar
  • 8,716
8 votes

Filter out ambiguous bases from a DNA sequence

There's an inconsistency between the two functions. check_and_clean_sequence() has an alphabet parameter, but this isn't used ...
Toby Speight's user avatar
  • 74.4k
7 votes
Accepted

The Genetic Code

Some notes: As others have already pointed out, you should use a hash instead of a gigantic case. But make sure your get operations on that hash are O(1), ...
tokland's user avatar
  • 11.1k
7 votes
Accepted

A classy DNA nucleobase counter

I don't really like self.sequence, it's only used in count_nucleobases, and doesn't seem to be needed as an attribute to the ...
Peilonrayz's user avatar
  • 43k
7 votes

A simple C++ class for packing DNA strings

The Interface ...
Martin York's user avatar
  • 94.6k
7 votes

Implementing a DNA codon table in C

The line (*aminoacid_string) = malloc(aminoacid_count); allocates aminoacid_count of bytes. The code needs that many ...
vnp's user avatar
  • 56.2k
7 votes

Implementing a DNA codon table in C

You should try to refactor the code to have less hard-coded constants. E.g. nucleobase_to_aminoacid has both tcag and codon_table hard-coded. That is in general something that hinders re-use. You ...
Hans Olsson's user avatar
7 votes

FASTA-to-tsv conversion script

Path? Surely path is not a single path, since you loop through it. So at the least, this is poorly-named and should be paths. ...
Reinderien's user avatar
  • 60.5k
7 votes
Accepted

Filter out ambiguous bases from a DNA sequence

From the bioinformatics side, not the python one: Your return will be non-useful for further processing whenever an ambiguous base has been present, because it changes index locations! You'll want to ...
Bennie's user avatar
  • 186
6 votes
Accepted

Reading string from a text file and returning the number of occurrences of each substring of length k

Code Review Replace: ...
Martin York's user avatar
  • 94.6k
6 votes
Accepted

A sequence of mistakes

Generally, these programming challenges don't require you to do validation. How strict do you make the validation? Why not verify that the string contains nothing but ACTGU? In any case, your ...
200_success's user avatar
6 votes

Simple program to split DNA sequences based on ambiguous content

The other review hits most of the important bits, but if you're writing software to classify DNA strings, I would bet that it's not the only processing you're ever going to need to do. With that in ...
Edward's user avatar
  • 66.4k
6 votes
Accepted

Viterbi algorithm implementation in C

Well, you are right that you rediscovered the megamoth, and it should be divided into easier to understand and maybe reusable parts. But let's first look at your 2 functions, which are both ...
Deduplicator's user avatar
  • 19.1k
6 votes

Counting relevant entries in a large bioinformatics file

Possible bug: ...
Imus's user avatar
  • 4,297
6 votes

Implementing a DNA codon table in C

In addition to current (and future) answers: You use malloc(), but from what I can see, you do not free() it later on. In my ...
esote's user avatar
  • 3,770
6 votes
Accepted

Genetic Sequence Visualizer - Generating large images

Parser Your parser has a bug in line 62: raw = ''.join([n for n in file.readlines() if not n.startswith('>')]).replace('\n', "").lower() will ...
FirefoxMetzger's user avatar
6 votes
Accepted

Highly nested bioinformatics processing

Non-code / very-high-level considerations. The first thing you can do to speed up the performance would be to get a better computer. My computer is several years old, but it runs the unmodified code ...
Peter Taylor's user avatar
  • 24.1k
6 votes
Accepted

Filtering FASTQ file based on read names from other file (how to increase performance) Python

Do not reinvent the wheel. There are bioinformatics tools that accomplish this task. To extract reads from fastq files by IDs, use seqtk subseq. Extract sequences ...
Timur Shtatland's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible