FASTA format: Difference between revisions

Content added Content deleted
mNo edit summary
Line 402: Line 402:
(print line)))))</lang>
(print line)))))</lang>


ref = ARGV[0]
=={{header|Crystal}}==
<lang crystal>(defn fasta [pathname]


id = seq = ""
=={{header|D}}==
fasta = {} of String => String
<lang d>import std.stdio, std.string;


File.each_line(ref) do |line|
void main() {
if line.starts_with?(">")
immutable fileName = "fasta_format_data.fasta";
if id != ""
fasta[id] = seq.sub(/\s/, "")
end
id = line.split(/\s/)[0].lstrip(">")
seq = ""
else
seq += line
end
end


bool first = true;


fasta[id] = seq.sub(/\s/, "")
foreach (const line; fileName.File.byLine) {
if (line[0] == '>') {
if (first) {
first = false;
} else {
writeln;
}


fasta.each do |k,v|
write(line[1 .. $].strip, ": ");
puts "#{k}: #{v}"
} else {
end
line.strip.write;
}
}


writeln;
writeln;