Hi Kathie,
I think the problem is that the BAM files you are mapping from already contain the RG:Z: tag, and you are adding another one.
To remove all the tags from the BAMs, you could do one the following:
1. Convert each BAM separately into sam keeping only 11 first fields:
$ samtools view -h a1.bam | cut -f1-11 > a1.sam
$ samtools view -h a2.bam | cut -f1-11 > a2.sam
$ samtools view -h a3.bam | cut -f1-11 > a3.sam
then map
$ STAR --outSAMattrRGline ID:C4HFC.1 SM:881_130918 , ID:C4HFC.2 SM:881_130918 , ID:C4HFC.3 SM:881_130918 --readFilesType SAM PE --readFilesIn a1.sam,a2.sam,a3.sam
Note that you do not need --readFilesCommand command in this case.
2. Or you can do all of the above on the fly:
Create a script convertBAM.sh that contains one line and make it executable:
samtools view -h $1 | cut -f1-11
Then map with
STAR --readFilesType SAM PE --readFilesCommand /path/to/convertBAM.sh --readFilesIn C4HFC.1.bam,C4HFC.2.bam,C4HFC.3.bam --outSAMattrRGline ID:C4HFC.1 SM:881_130918 , ID:C4HFC.2 SM:881_130918 , ID:C4HFC.3 SM:881_130918
The commands above will add the ID tag for each of the reads, and ID: SM: into @RG line in the header.
If you want to add SM to each read, you can experiment with --outSAMattrRGline ID:"C4HFC.1 SM:881_130918" , ID:"C4HFC.2 SM:881_130918" , ID:"C4HFC.3 SM:881_130918"
but I do not recommend it as it defies the standard BAM formatting rules.
Cheers
Alex