{"action":"created","issue":{"url":"https://api.github.com/repos/samtools/hts-specs/issues/73","labels_url":"https://api.github.com/repos/samtools/hts-specs/issues/73/labels{/name}","comments_url":"https://api.github.com/repos/samtools/hts-specs/issues/73/comments","events_url":"https://api.github.com/repos/samtools/hts-specs/issues/73/events","html_url":"https://github.com/samtools/hts-specs/issues/73","id":60692098,"number":73,"title":"Issues with definition/use of \"read\" and \"segment\"","user":{"login":"gerton","id":4059966,"avatar_url":"https://avatars.githubusercontent.com/u/4059966?v=3","gravatar_id":"","url":"https://api.github.com/users/gerton","html_url":"https://github.com/gerton","followers_url":"https://api.github.com/users/gerton/followers","following_url":"https://api.github.com/users/gerton/following{/other_user}","gists_url":"https://api.github.com/users/gerton/gists{/gist_id}","starred_url":"https://api.github.com/users/gerton/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gerton/subscriptions","organizations_url":"https://api.github.com/users/gerton/orgs","repos_url":"https://api.github.com/users/gerton/repos","events_url":"https://api.github.com/users/gerton/events{/privacy}","received_events_url":"https://api.github.com/users/gerton/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/samtools/hts-specs/labels/sam","name":"sam","color":"0052cc"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2015-03-11T17:02:54Z","updated_at":"2015-03-12T10:02:30Z","closed_at":null,"body":"Dear all,\r\n\r\nWe have been going through the SAM specification with a fine comb, and\r\nfound a few issues.  \r\n\r\nThe main issue is that there seems to be a confusion about ‘read’ and\r\n‘segment’ at various places, and most importantly, the constituent parts\r\nof a chimeric alignment are not currently chained together, so that to\r\nfind all records of a chimeric alignment you’ll have to read the entire\r\nBAM file.\r\n\r\nAnother, smaller issue is that flag bit 0x1 appears to be superfluous\r\ngiven the state of 0x40 and 0x80; and in the proposed spec, you cannot\r\nwork out whether a template has multiple reads (rather than segments)\r\ncontributing to it, other than by recovering all records.\r\n\r\nJust to be clear, we think that the intended concepts of template, read\r\nand segment are:\r\n\r\n- template: the physical molecule that has been sequenced;\r\n\r\n- read: a unit of sequence information that came off the sequencing\r\nmachine;\r\n\r\n- segment: a unit of sequence information, part of a read, that can be\r\ncontiguously aligned (with only short indels) to a reference sequence;\r\n\r\nand that a SAM record refers to an alignment of a segment.\r\n\r\n\r\nHere is a list of proposed edits to the spec:\r\n\r\n\r\nPage 2, section 1.2:\r\n\r\nEdit: Linear alignment: an alignment of a **segment** to a single\r\nreference sequence ….\r\n\r\n\r\nPage 2, section 1.2:\r\n\r\nEdit: Chimeric alignment: an alignment of a read that cannot be represented as a **single** linear alignment. […] All the SAM records in a chimeric alignment have the same QNAME ~~and the same\r\nvalues for 0x40 and ox80 tags (see Section 1.4)~~\r\nThe 0x40 and 0x80 flag definitions refer to **segments** rather than reads, so different segments should be able to have the appropriate flags.\r\n\r\n\r\nPage 2, section 1.2:\r\n\r\nEdit: Multiple mapping: replace “read” by “segment” throughout.\r\n\r\n\r\nPage 4, section 1.4:\r\n\r\nCol 7, RNEXT […]  Ref. name of the ~~mate /~~ next **segment**\r\nHaving RNEXT/PNEXT point to the next segment rather than the next read, allows all SAM records related to a single read to be efficiently recovered from a large BAM file.  In addition, the concept of a \"mate\" is never defined, and it refers to a read not a segment.\r\n\r\nCol 8, PNEXT […]  Position of the ~~mate /~~ next **segment**\r\n\r\nPage 4, section 1.4. As it stands, bit 0x1 signifies whether a template\r\nhas multiple segments.  If it does not, the first segment is also the\r\nlast, and therefore bits 0x40 and 0x80 are both set; and if they’re both\r\nset, there can only be one segment.  Therefore bit 0x1 is redundant.  If\r\nits meaning is changed into “template having multiple **reads** in\r\nsequencing”, it allows users to determine whether a template has\r\nmultiple reads; this information can be inferred from the whole set of\r\nchimeric reads, but these first need to be obtained from the BAM file.\r\n In addition, the proposed meaning is identical to the current meaning\r\nof this bit.\r\n\r\nPage 4, section 1.4. For each read ~~/ contig~~ in a\r\nSAM file, it is required that one and only one […].\r\nThe concept of a \"contig\" is not defined.\r\n\r\nPage 5, section 1.4. “If 0x40 and 0x80 are both set, the read is part of\r\na linear template, but is neither the first nor the last read”.\r\n\r\nThis does not seem to make sense — this redefines the meaning of 0x40 ==\r\n0x80 == 1 to be the same as 0x40 == 0x80 == 0, for no reason that is\r\napparent to us.  It also clashes with the proposed redefinition of the\r\nmeaning of the 0x1 bit.\r\n\r\nPage 5, section 1.4, “…This may happen for a **chimeric alignment** or\r\nif the index is lost in data processing”.  \r\n\r\n\r\nPage 5, section 1.4, “If 0x1 is unset, no assumption can be made about\r\n0x2, 0x8, 0x20, 0x40 and 0x80”.  If the proposed redefinition of the\r\nmeaning of 0x1 is accepted, this line should be removed altogether, as\r\nsingle reads can still consist of multiple segments.\r\n\r\n\r\nPage 5, section 1.4. “RNEXT: Reference sequence name of the primary\r\nalignment of the NEXT **segment** in the template.  For the last\r\n**segment**, the next **segment** is the first **segment** in the\r\ntemplate. […]\r\n\r\n\r\nPage 5, “PNEXT: Postition of the primary alignment of the NEXT\r\n**segment** in the template. […]\r\n\r\n\r\n\r\nGerton and Daniel.\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/samtools/hts-specs/issues/comments/78452068","html_url":"https://github.com/samtools/hts-specs/issues/73#issuecomment-78452068","issue_url":"https://api.github.com/repos/samtools/hts-specs/issues/73","id":78452068,"user":{"login":"jkbonfield","id":2210525,"avatar_url":"https://avatars.githubusercontent.com/u/2210525?v=3","gravatar_id":"","url":"https://api.github.com/users/jkbonfield","html_url":"https://github.com/jkbonfield","followers_url":"https://api.github.com/users/jkbonfield/followers","following_url":"https://api.github.com/users/jkbonfield/following{/other_user}","gists_url":"https://api.github.com/users/jkbonfield/gists{/gist_id}","starred_url":"https://api.github.com/users/jkbonfield/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jkbonfield/subscriptions","organizations_url":"https://api.github.com/users/jkbonfield/orgs","repos_url":"https://api.github.com/users/jkbonfield/repos","events_url":"https://api.github.com/users/jkbonfield/events{/privacy}","received_events_url":"https://api.github.com/users/jkbonfield/received_events","type":"User","site_admin":false},"created_at":"2015-03-12T10:02:30Z","updated_at":"2015-03-12T10:02:30Z","body":"Ah I finally found the thread on samtools-devel, along with the whopping zero replies. :-)\r\n\r\nhttps://sourceforge.net/p/samtools/mailman/message/33003353/\r\n\r\nHow well does this tie in with your suggestions?"}}