How to merge multiple tab-delimitated files
I have several (about 40 files) tab-delimited files for each genome (having k-mer counts). The format is
AAAAAAAAAA 2
AAAAAAAAAC 8
AAAAAAAAAG 2
AAAAAAAAAT 8
AAAAAAAACA 27
I want to merge them. My ultimate aim is to make dataset of kmers of each genome. I have used KMC to calculate kmers.
Any suggestions to use other tools are also welcomed.
• 1,163 views
•
link
0 answers
No answers yet.
Log in to answer this question.
How do you want to merge them? Does cat not work?
Hello doctor.dee005!
We believe that this post does not fit the main topic of this site.
Not related to bioinformatics specifically, pure programming question. See unix join/cut/paste etc.
For this reason we have closed your question. This allows us to keep the site focused on the topics that the community can help with.
If you disagree please tell us why in a reply below, we'll be happy to talk about it.
Cheers!
IMO, it is not pure. He is trying to get help from other members who can share knowledge of how to deal with this data and use case. It's called networking and in bioinformatic context. I don't know who closed this question, or how it got closed. Anyway, there are tons of questions like this one on this forum. So it is unfair to close it thereby kicks the OP's butt before he can get some help for his bioinformatic work. Is it not the purpose of the forum to help people with bioinformatic work?
Example of similar question: awk format question Replace Sequence IDs in many text files (newick format) - Change script Help with perl script to subset a fasta file?
It was closed by me, after discussing with the other moderators.
It is a pure programming question because the content of the file doesn’t affect the task at hand. The data could just be a bunch of completely random strings and numbers and the task would remain the same — the fact that it happens to be kmers and genomes isn’t actually relevant. OP has also not shown any effort to solve the problem themselves. Without wishing to patronise or condescend anyone, this is not a very difficult task, and in fact would be an excellent learning exercise for the OP to try and resolve. Low effort questions which are rewarded with answers, only encourage other low-effort questions. The moderators feel we’ve seen a particular spike of such lately, so maybe you’re right, and we’re being more punitive than usual, but it is in the interests of the forum itself.
Yes, there are many ‘pure’ programming questions that get answered on the forum, but that does not mean that that is the norm. The fact that those questions got answers and not closed if fortunate for the OP, but it is not a precedent we want to set.
And, I’m not really sure what you mean by networking, I think that’s stretching it.
If you guys have done some discussion before closing the question, I have nothing to say much about it. I will stop debating, but want to let you guys know my point of view:
'pure' (read impure) programming questions are often found here. tags of programming languages (i.e. Perl, Python, R, etc) are among the most prominent tags. That says something about users' interest. Unless the admin group really want to redefine forums 'scope', shooting down some 'unlucky' questions only disappoints the effected posters. IMHO, the forum can adapt to reflex users needs. I would bet 50% or more members who come here are not programmers. So stressing on 'effort' to solve the problem should be at the level of giving a clear question that others can understand and solve.
Furthermore, I tried but could not find any written forum rule or agreement that users are not allowed or discouraged to post pure programming questions.
I think you’re missing the subtle distinction. Questions with specific programming languages are not off topic. For example, questions about BioPython or Bioconductor which necessitate python/R tags respectively are absolutely on topic, so long as that question does not amount to “I don’t know how to do X, nor have I even tried - please do my work for me”.
We are not redifining the scope of the forum, we are ‘enforcing’ it’s existing remit; from the help page:
I agree, many if not most of the sites visitors will be people who are not advanced programmers - but then neither am I. It is important that people also learn the skills, not just get an answer to that question. It’s very much a case of the old adage: “give a man a fish” vs. “teach a man to fish”.
The countless threads we have closed for being unrelated to bioinformatics problems are plenty of examples of written confirmation that pure proframming questions are off topic. Believe us, we know StackOverflow and its ilk are hostile places, especially to novices, but those forums exist specifically to handle these types of questions, and what’s more, viable solution to the OPs problems absolutely exist already. It would be closed as a duplicate on those sites, and rightly so.
Please provide at least 2 example input files and expected output.
You can find two files here. The expected output file should be like this ----
In this format I want to merge two files.
We need to read all files into one list, then use merge, see:
If the files are all in the same top-to-bottom order of kmers, just
cutthe first column, and paste all the other files end-to-end.