code: def readSAM(SAMfile,header=False):
      if header==True:
          f=open(SAMfile,"r+")
          head=[]
          for line in f.readlines():
              if line[0]=="@":
                  head.append(line)
              else:
                  continue
          f.close()
      sam=pd.read_table(SAMfile,sep="this_gives_one_column",comment="@",header=None)
      sam=pd.DataFrame(sam[0].str.split("\t").tolist())
      acols=[0,1,2,3,4,5,6,7,8,9]
      sam_=sam[acols]
      samcols=sam.columns.tolist()
      bcols=[ s for s in samcols if s not in acols ]
      sam_[10]=sam[bcols[0]]
      if len(bcols) > 1:
          for c in bcols[1:]:
              sam_[10]=sam_[10].astype(str)
              sam[c]=sam[c].astype(str)
              sam_[10]=sam_[10]+"\t"+sam[c]
      sam_.columns=['QNAME','FLAG','RNAME','POS','MAPQ','CIGAR','RNEXT','PNEXT','TLEN','SEQ','QUAL']
      if header==True:
          return sam_, head
      else:
          return sam_