#!/bin/sh
#
# mergepeaks.sh (c) Magnus Palmblad, Leiden University Medical Center 2009-
#
# This program is free software; you can redistribute it and/or modify it under the terms of the
# Creative Commons Attribution-Share Alike 3.0 License (http://creativecommons.org/licenses/by-sa/3.0/)
#
# This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
# without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
#
# Contact information: n.m.palmblad@lumc.nl
#
# mergepeaks.sh merges .peaks files created by Xtractor into a single file, column by column for further
# analysis in Excel or any other program for mass spectrometry profiling data analysis.
#
# Usage: ./mergepeaks.sh > output_file.txt
#
ls *.peaks | awk 'BEGIN {printf("feature");} {gsub(/.xy.peaks/,""); printf(",%s",$0);} {next} END {printf("\n");}'
cat *.peaks | awk '{A[$1]=A[$1] "," $3;} {next} END {for(x in A) print x A[x];}'